DropBear.Codex.Caching
2024.3.6
dotnet add package DropBear.Codex.Caching --version 2024.3.6
NuGet\Install-Package DropBear.Codex.Caching -Version 2024.3.6
<PackageReference Include="DropBear.Codex.Caching" Version="2024.3.6" />
paket add DropBear.Codex.Caching --version 2024.3.6
#r "nuget: DropBear.Codex.Caching, 2024.3.6"
// Install DropBear.Codex.Caching as a Cake Addin
#addin nuget:?package=DropBear.Codex.Caching&version=2024.3.6
// Install DropBear.Codex.Caching as a Cake Tool
#tool nuget:?package=DropBear.Codex.Caching&version=2024.3.6
DropBear Codex Caching Library
The DropBear Codex Caching Library offers a robust and flexible caching solution tailored for .NET applications. It supports diverse caching strategies, such as InMemory, SQLite, and FasterKV caches. Enhanced with features like cache preloading, dynamic fallback mechanisms, tag-based invalidation, automatic cache refresh, encrypted cache storage, and secure cache access, it aims to optimize performance and ensure data security across .NET applications.
Features
- Versatile Caching Strategies: Utilize InMemory, SQLite, and FasterKV caching based on your application's specific requirements.
- Cache Preloading: Elevate performance by preloading critical data into the cache upon application startup.
- Dynamic Cache Fallback Mechanism: Seamlessly fallback to alternative caches or direct data sources in the event of cache misses or operational failures.
- Encrypted Cache Storage: Secure sensitive information with encrypted cache entries.
Getting Started
Prerequisites
- .NET Core 3.1 or .NET 5/6/7+
- Microsoft.Extensions.Hosting integration for leveraging .NET's generic host capabilities.
Installation
Incorporate the DropBear Codex Caching Library into your project by adding it as a NuGet package dependency or by directly referencing the project.
dotnet add package DropBear.Codex.Caching
Configuration
- Set Up Caching Options: Initialize the caching library within your
Startup.cs
or an equivalent configuration setup, specifying your caching strategy preferences.
public void ConfigureServices(IServiceCollection services)
{
ConfigureCachingOptions(services, Configuration);
}
private static void ConfigureCachingOptions(IServiceCollection services, IConfiguration configuration)
{
services.AddCodexCaching(configuration, configure =>
{
configure.FasterKVOptions.Enabled = true;
configure.SQLiteOptions.Enabled = true;
configure.InMemoryOptions.Enabled = true;
// Set the default cache duration to 5 minutes
configure.DefaultCacheDurationMinutes = TimeSpan.FromMinutes(5);
// Set the encryption options
configure.EncryptionOptions.Enabled = true;
configure.EncryptionOptions.EncryptionApplicationName = "CodexCaching";
configure.EncryptionOptions.KeyStoragePath = @"C:\Temp\Keys";
// Set the serialization options
configure.SerializationOptions.Enabled = true;
configure.SerializationOptions.Format = SerializationFormat.MessagePack;
// Set the compression options
configure.CompressionOptions.Enabled = true;
configure.CompressionOptions.Algorithm = CompressionAlgorithm.LZ4;
// Set the SQLite options
configure.SQLiteOptions.CacheName = "SQLiteCache";
// Set the InMemory options
configure.InMemoryOptions.CacheName = "InMemoryCache";
// Set the FasterKV options
configure.FasterKVOptions.CacheName = "FasterKVCache";
},preloaders: new List<ICachePreloader> { new MyCachePreloader() });
}
- Incorporate Cache Preloaders: For employing cache preloading, define preloaders and add them during configuration.
services.AddCodexCaching(options => { /* Configuration details */ }, preloaders: new List<ICachePreloader> { new MyCachePreloader() });
Usage
Leverage ICacheService
within your services or controllers to manage cache interactions efficiently.
public class MyService
{
private readonly ICacheService _cacheService;
public MyService(ICacheService cacheService)
{
_cacheService = cacheService;
}
public async Task<MyData> GetDataAsync(string key)
{
return await _cacheService.GetAsync<MyData>(key, () => FetchDataFromStore(key));
}
}
Contributing
We warmly welcome contributions! To maintain a constructive and inclusive community, we ask that you first review our contributing guidelines and code of conduct before submitting pull requests or issues.
License
This project adheres to the GNU Lesser General Public License. For more details, refer to the LICENSE page.
Acknowledgments
- Special thanks to the EasyCaching project for the foundational caching mechanisms.
- Appreciation for our contributors and community members for their insightful feedback and suggestions.
Disclaimer: As this project is under active development, features might be subject to change. The current version should be considered beta and not yet suited for production use.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. 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. |
-
net8.0
- DropBear.Codex.AppLogger (>= 2024.3.6)
- EasyCaching.Core (>= 1.9.2)
- EasyCaching.Extensions.EasyCompressor (>= 2.0.2)
- EasyCaching.FasterKv (>= 1.9.2)
- EasyCaching.InMemory (>= 1.9.2)
- EasyCaching.Serialization.Json (>= 1.9.2)
- EasyCaching.Serialization.MemoryPack (>= 1.9.2)
- EasyCaching.Serialization.MessagePack (>= 1.9.2)
- EasyCaching.SQLite (>= 1.9.2)
- EasyCompressor.LZ4 (>= 2.0.2)
- MemoryPack (>= 1.21.0)
- Microsoft.AspNetCore.DataProtection (>= 8.0.3)
- Microsoft.Extensions.Hosting (>= 8.0.0)
- Microsoft.Extensions.Options.DataAnnotations (>= 8.0.0)
- ServiceStack.Text (>= 8.2.2)
- ZString (>= 2.6.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 |
---|