Kre.Caching.InMemory 3.0.0
Kre.Caching.InMemory
Overview
Kre.Caching.InMemory is a .NET library that provides a pass-through implementation of the MemoryCache with additional support for async operations.
It allows developers to utilize the features of MemoryCache while extending its capabilities for asynchronous usage.
Features
- Pass-through MemoryCache Implementation: Provides a pass-through implementation of
MemoryCachewith additional support for async operations. - Supports Async Operations: Supports asynchronous operations for adding, retrieving, and updating items in the cache.
- Flexible Usage: Offers a flexible API for interacting with the cache, allowing developers to easily store, retrieve, and remove items.
- Expiry Support: Supports caching with expiration, enabling developers to specify expiration policies for cached items.
- Singleton Default Instance:
Kre.Caching.InMemoryincludes a singleton default instance for easy access to the caching functionality throughout the application. Developers can leverage this default instance to simplify caching operations and improve code readability. - Injection: Easily integrates with
IServiceCollection.
Installation
To install Kre.Caching.InMemory in your project, you can use NuGet Package Manager:
Requirements
- .NET 8.0 or later
Usage
Here's a basic example demonstrating how to use Kre.Caching.InMemory in your application:
using Kre.Caching.InMemory;
// Create a cache instance
var cache = Cache.Default;
// Add an item to the cache
cache.Set("myKey", "myValue");
// Retrieve the item from the cache
var value = cache.Get<string>("myKey");
Console.WriteLine(value); // Output: myValue
No packages depend on Kre.Caching.InMemory.
.NET 9.0
- Kre.Caching.Abstractions (>= 3.0.0)