CodeDesignPlus.Net.Cache.Abstractions
0.5.0-beta.60
dotnet add package CodeDesignPlus.Net.Cache.Abstractions --version 0.5.0-beta.60
NuGet\Install-Package CodeDesignPlus.Net.Cache.Abstractions -Version 0.5.0-beta.60
<PackageReference Include="CodeDesignPlus.Net.Cache.Abstractions" Version="0.5.0-beta.60" />
paket add CodeDesignPlus.Net.Cache.Abstractions --version 0.5.0-beta.60
#r "nuget: CodeDesignPlus.Net.Cache.Abstractions, 0.5.0-beta.60"
// Install CodeDesignPlus.Net.Cache.Abstractions as a Cake Addin #addin nuget:?package=CodeDesignPlus.Net.Cache.Abstractions&version=0.5.0-beta.60&prerelease // Install CodeDesignPlus.Net.Cache.Abstractions as a Cake Tool #tool nuget:?package=CodeDesignPlus.Net.Cache.Abstractions&version=0.5.0-beta.60&prerelease
Okay, I'll create a README.md
file for the CodeDesignPlus.Net.Cache
library, following the structure you've provided and incorporating information relevant to a caching library.
# CodeDesignPlus.Net.Cache
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=CodeDesignPlus.Net.Cache&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=CodeDesignPlus.Net.Cache)
[![Bugs](https://sonarcloud.io/api/project_badges/measure?project=CodeDesignPlus.Net.Cache&metric=bugs)](https://sonarcloud.io/summary/new_code?id=CodeDesignPlus.Net.Cache)
[![Code Smells](https://sonarcloud.io/api/project_badges/measure?project=CodeDesignPlus.Net.Cache&metric=code_smells)](https://sonarcloud.io/summary/new_code?id=CodeDesignPlus.Net.Cache)
[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=CodeDesignPlus.Net.Cache&metric=coverage)](https://sonarcloud.io/summary/new_code?id=CodeDesignPlus.Net.Cache)
[![Duplicated Lines (%)](https://sonarcloud.io/api/project_badges/measure?project=CodeDesignPlus.Net.Cache&metric=duplicated_lines_density)](https://sonarcloud.io/summary/new_code?id=CodeDesignPlus.Net.Cache)
[![Vulnerabilities](https://sonarcloud.io/api/project_badges/measure?project=CodeDesignPlus.Net.Cache&metric=vulnerabilities)](https://sonarcloud.io/summary/new_code?id=CodeDesignPlus.Net.Cache)
## Description
The `CodeDesignPlus.Net.Cache` project provides a flexible and abstract caching layer for .NET applications. It allows you to easily integrate different caching solutions (like Redis, Memcached, or in-memory caches) by using a common interface. This library aims to improve performance by reducing the need to retrieve data from the original source repeatedly.
## Table of Contents
- [About The Project](#about-the-project)
- [Installation](#installation)
- [Usage](#usage)
- [Roadmap](#roadmap)
- [Contributing](#contributing)
- [License](#license)
- [Contact](#contact)
## About The Project
The `CodeDesignPlus.Net.Cache` library is designed to simplify caching in .NET applications by providing an abstraction over various caching implementations. It promotes maintainability and testability through a consistent API.
### Key Features
- **Abstract Caching Interface (`ICacheManager`):** Defines a common interface for interacting with different cache providers, supporting asynchronous operations.
- **Generic Operations:** Supports storing and retrieving any type of data in the cache with type safety using generics.
- **Asynchronous Operations:** All operations are fully asynchronous, ensuring a non-blocking approach and improving overall performance.
- **Expiration Control:** Allows setting an expiration time for cached items.
- **Multiple Cache Provider Implementations:** Designed to easily integrate with various cache providers (e.g. Redis, Memcached, In-Memory, etc.).
## Installation
To install the package, run the following command:
```bash
dotnet add package CodeDesignPlus.Net.Cache
Usage
Here's a basic example of how to use the ICacheManager
:
// Assuming you have an instance of ICacheManager (e.g., RedisCacheManager or MemcachedCacheManager)
// through dependency injection
public class MyService
{
private readonly ICacheManager _cacheManager;
public MyService(ICacheManager cacheManager)
{
_cacheManager = cacheManager;
}
public async Task<MyData> GetDataAsync(string key)
{
// Try to get the data from cache first
var cachedData = await _cacheManager.GetAsync<MyData>(key);
if (cachedData != null)
{
return cachedData;
}
// If data isn't in cache, fetch from the source
var data = await GetDataFromSourceAsync(key); // Some function to retrieve data
// Store in cache for future use
await _cacheManager.SetAsync(key, data, TimeSpan.FromMinutes(10));
return data;
}
// Assume this method return a task with the result
private async Task<MyData> GetDataFromSourceAsync(string key)
{
// Your implementation here
await Task.Delay(100);
return new MyData() { Id=key, Name = "Example " + key};
}
}
// A simple Model
public class MyData {
public string Id { get; set;}
public string Name { get; set; }
}
For more detailed information and advanced use cases, please refer to our documentation at CodeDesignPlus Doc.
Roadmap
Refer to issues for a list of proposed features and known issues.
Contributing
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
License
Distributed under the MIT License. See LICENSE
for more information.
Contact
CodeDesignPlus - @CodeDesignPlus - codedesignplus@outlook.com
Project Link: CodeDesignPlus.Net.Cache
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. |
-
net9.0
NuGet packages (1)
Showing the top 1 NuGet packages that depend on CodeDesignPlus.Net.Cache.Abstractions:
Package | Downloads |
---|---|
CodeDesignPlus.Net.Redis.Cache.Abstractions
CodeDesignPlus.Net.Core.Abstractions provides essential interfaces and abstract classes for the CodeDesignPlus.Net.Core library, enabling a clean and maintainable architecture for .NET Core applications. This library defines the core contracts and abstractions that facilitate dependency injection, testing, and extensibility. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
0.5.0-beta.60 | 34 | 1/7/2025 |
0.5.0-beta.59 | 35 | 1/7/2025 |
0.5.0-beta.57 | 29 | 1/7/2025 |
0.5.0-beta.56 | 41 | 1/6/2025 |
0.5.0-beta.54 | 34 | 1/6/2025 |
0.5.0-beta.39 | 65 | 1/3/2025 |
0.5.0-beta.38 | 56 | 1/3/2025 |