Net.Cache
1.3.0
See the version list below for details.
dotnet add package Net.Cache --version 1.3.0
NuGet\Install-Package Net.Cache -Version 1.3.0
<PackageReference Include="Net.Cache" Version="1.3.0" />
paket add Net.Cache --version 1.3.0
#r "nuget: Net.Cache, 1.3.0"
// Install Net.Cache as a Cake Addin #addin nuget:?package=Net.Cache&version=1.3.0 // Install Net.Cache as a Cake Tool #tool nuget:?package=Net.Cache&version=1.3.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.Retrieval and Management
: UtilizeGet
,Add
,Delete
, andUpdate
methods for managing cache contents.Dynamic Cache Management
: Efficiently handle caching with the ability to dynamically add or update values when not present usingGetOrAdd
.
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, Retrieving, and Managing Values
// Storing a value
cache.Add(1, "Hello World");
// Retrieving a value
string value = cache.Get(1); // Outputs: Hello World
// Updating a value
cache.Update(1, "Updated Value");
// Deleting a value
cache.Delete(1);
Adding Values Dynamically
Leverage the GetOrAdd
method to add values to the cache dynamically if they don't already exist, with or without additional parameters.
// Adding a value dynamically without parameters
string value = cache.GetOrAdd(2, () => "New Value");
// Adding a value dynamically with parameters
string complexValue = cache.GetOrAdd(3, x => $"Value with {x.Length} parameters", "param1", "param2");
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. 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. |
.NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.1 is compatible. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- 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.