DropBear.CacheManager.Core
0.1.6
dotnet add package DropBear.CacheManager.Core --version 0.1.6
NuGet\Install-Package DropBear.CacheManager.Core -Version 0.1.6
<PackageReference Include="DropBear.CacheManager.Core" Version="0.1.6" />
paket add DropBear.CacheManager.Core --version 0.1.6
#r "nuget: DropBear.CacheManager.Core, 0.1.6"
// Install DropBear.CacheManager.Core as a Cake Addin
#addin nuget:?package=DropBear.CacheManager.Core&version=0.1.6
// Install DropBear.CacheManager.Core as a Cake Tool
#tool nuget:?package=DropBear.CacheManager.Core&version=0.1.6
DropBear CacheManager
This package provides a simple and flexible way to manage caching in your .NET applications. It supports multiple caching providers including In-Memory, Disk, SQLite, and FasterKV.
Installation
Install the NuGet package in your project:
dotnet add package DropBear.CacheManager
Usage
Using the Service Collection Extension
In your Startup.cs
or wherever you configure your services, add the following code:
services.AddCacheManagerCore(options =>
{
options.UseMemoryCache = true;
options.UseDiskCache = true;
options.UseSQLiteCache = true;
options.UseFasterKvCache = true;
options.DefaultLoggingLevel = LogLevel.Debug;
});
Using the CacheManagerFactory
If you're not using a ServiceCollection
, you can use the CacheManagerFactory
to create an instance of CacheManagerCore
:
var factory = new CacheManagerFactory();
var cacheManager = factory.Create(options =>
{
options.UseMemoryCache = true;
options.UseDiskCache = true;
options.UseSQLiteCache = true;
options.UseFasterKvCache = true;
options.DefaultLoggingLevel = LogLevel.Debug;
});
Basic Operations
The CacheManagerCore
provides methods for adding, retrieving, and removing cache items:
// Add to cache
await cacheManager.AddToCache("key", "value", TimeSpan.FromMinutes(5),CacheType.FasterKV);
// Check if key exists in cache
bool exists = await cacheManager.ExistsInCache("key",CacheType.FasterKV);
// Retrieve from cache
string value = await cacheManager.GetFromCache<string>("key",CacheType.FasterKV);
// Remove from cache
await cacheManager.RemoveFromCache("key",CacheType.FasterKV);
Replace CacheType
with the name of the cache provider you want to use (,CacheType.Memory
, ,CacheType.Disk
, ",CacheType.SQlite"
, or ",CacheType.FasterKV"
).
Test Use
void Main()
{
TestCacheManagerCore().Wait();
}
public async Task TestCacheManagerCore()
{
var factory = new CacheManagerFactory();
var cacheManager = factory.Create(options =>
{
options.UseMemoryCache = true;
options.UseDiskCache = true;
options.UseSQLiteCache = true;
options.UseFasterKvCache = true;
options.DefaultLoggingLevel = LogLevel.Debug;
});
// Add to cache
await cacheManager.AddAsync("key", "value", TimeSpan.FromMinutes(5),CacheType.FasterKV);
Console.WriteLine("Item added to cache.");
// Check if key exists in cache
bool exists = await cacheManager.ExistsAsync("key",CacheType.FasterKV);
Console.WriteLine($"Item exists in cache: {exists}");
// Retrieve from cache
string value = await cacheManager.GetAsync<string>("key",CacheType.FasterKV);
Console.WriteLine($"Retrieved item from cache: {value}");
// Remove from cache
await cacheManager.RemoveAsync("key",CacheType.FasterKV);
Console.WriteLine("Item removed from cache.");
// Check if key exists in cache
exists = await cacheManager.ExistsAsync("key",CacheType.FasterKV);
Console.WriteLine($"Item exists in cache: {exists}");
return;
}
License
This project is licensed under the MIT License.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net7.0 is compatible. 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. |
-
net7.0
- EasyCaching.Core (>= 1.9.0)
- EasyCaching.Disk (>= 1.9.0)
- EasyCaching.Extensions.EasyCompressor (>= 1.4.0)
- EasyCaching.FasterKv (>= 1.9.0)
- EasyCaching.InMemory (>= 1.9.0)
- EasyCaching.Serialization.MessagePack (>= 1.9.0)
- EasyCaching.SQLite (>= 1.9.0)
- EasyCompressor.LZMA (>= 1.4.0)
- Lamar (>= 12.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 7.0.1)
- Microsoft.Extensions.Logging.Console (>= 7.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|
Released under MIT license.