Net.Cache
1.1.0
See the version list below for details.
dotnet add package Net.Cache --version 1.1.0
NuGet\Install-Package Net.Cache -Version 1.1.0
<PackageReference Include="Net.Cache" Version="1.1.0" />
paket add Net.Cache --version 1.1.0
#r "nuget: Net.Cache, 1.1.0"
// Install Net.Cache as a Cake Addin #addin nuget:?package=Net.Cache&version=1.1.0 // Install Net.Cache as a Cake Tool #tool nuget:?package=Net.Cache&version=1.1.0
Net.Cache
Overview
Net.Cache is a comprehensive caching library for .NET, designed to offer versatile tools for cache management.
The library focuses on facilitating key-value based caching operations and provides a default implementation with InMemoryStorageProvider
.
It allows for easy integration and extension, enabling developers to use different caching strategies while maintaining a consistent interface.
Features
Generic Caching Mechanism
: Supports any data type for keys and values, requiring keys to be equatable and non-nullable.Default In-Memory Caching
: IncludesInMemoryStorageProvider
for out-of-the-box in-memory caching.Customizable Storage Providers
: Easily extend or implement custom storage providers to suit various caching needs.Safe Value Retrieval
: UtilizeTryGetValue
for safe retrieval, reducing the risk of exceptions with missing keys.Dynamic Cache Management
: Efficiently handle caching with the ability to dynamically add values when not present.
Getting Started
Installation
Install Net.Cache
via the NuGet package manager or clone the repository into your project.
Usage
Implementing Custom Storage Providers
Create custom storage providers by implementing the IStorageProvider<TKey, TValue>
interface.
Alternatively, use the provided InMemoryStorageProvider<TKey, TValue>
.
var inMemoryStorage = new InMemoryStorageProvider<int, string>();
Using CacheProvider
Manage your caching logic with CacheProvider<TKey, TValue>
, which can handle multiple storage providers including custom ones.
var cache = new CacheProvider<int, string>(inMemoryStorage);
Storing and Retrieving Values
Easily store and retrieve values using keys.
// Storing a value
cache.Store(1, "Hello World");
// Retrieving a value
if (cache.TryGetValue(1, out var value)) {
Console.WriteLine(value); // Outputs: Hello World
}
Adding Values Dynamically
Leverage the GetOrAdd method to add values to the cache dynamically if they don't already exist.
string value = cache.GetOrAdd(2, () => "New Value");
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net6.0
- No dependencies.
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Net.Cache:
Package | Downloads |
---|---|
Net.Cache.DynamoDb
Net.Cache.DynamoDb is a specialized extension of the Net.Cache library, providing an abstract base class for DynamoDB storage providers. |
GitHub repositories
This package is not used by any popular GitHub repositories.
- CacheProvider working with collection of StorageProviders
- CacheProvider receive valueFactory function as method parameter
- Created InMemoryStorageProvider
Full changes can found here: https://github.com/The-Poolz/Net.Cache/releases/tag/v1.1.0