DropBear.CacheManager.Core 0.1.6

The owner has unlisted this package. This could mean that the package is deprecated, has security vulnerabilities or shouldn't be used anymore.
dotnet add package DropBear.CacheManager.Core --version 0.1.6
NuGet\Install-Package DropBear.CacheManager.Core -Version 0.1.6
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="DropBear.CacheManager.Core" Version="0.1.6" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add DropBear.CacheManager.Core --version 0.1.6
#r "nuget: DropBear.CacheManager.Core, 0.1.6"
#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 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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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.