Net.Cache 1.3.5

dotnet add package Net.Cache --version 1.3.5                
NuGet\Install-Package Net.Cache -Version 1.3.5                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Net.Cache" Version="1.3.5" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Net.Cache --version 1.3.5                
#r "nuget: Net.Cache, 1.3.5"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Net.Cache as a Cake Addin
#addin nuget:?package=Net.Cache&version=1.3.5

// Install Net.Cache as a Cake Tool
#tool nuget:?package=Net.Cache&version=1.3.5                

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: Includes InMemoryStorageProvider 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: Utilize Get, Add, Delete, and Update methods for managing cache contents.
  • Dynamic Cache Management: Efficiently handle caching with the ability to dynamically add or update values when not present using GetOrAdd.

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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .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.

Version Downloads Last updated
1.3.5 620 8/20/2024
1.3.4 340 7/10/2024
1.3.2 661 5/17/2024
1.3.1 346 3/20/2024
1.3.0 894 3/19/2024
1.1.0 1,151 1/15/2024
1.0.0 306 12/4/2023