Cachey.Persistence.SQLite
1.0.2
See the version list below for details.
dotnet add package Cachey.Persistence.SQLite --version 1.0.2
NuGet\Install-Package Cachey.Persistence.SQLite -Version 1.0.2
<PackageReference Include="Cachey.Persistence.SQLite" Version="1.0.2" />
<PackageVersion Include="Cachey.Persistence.SQLite" Version="1.0.2" />
<PackageReference Include="Cachey.Persistence.SQLite" />
paket add Cachey.Persistence.SQLite --version 1.0.2
#r "nuget: Cachey.Persistence.SQLite, 1.0.2"
#:package Cachey.Persistence.SQLite@1.0.2
#addin nuget:?package=Cachey.Persistence.SQLite&version=1.0.2
#tool nuget:?package=Cachey.Persistence.SQLite&version=1.0.2
Cachey
Cachey is a lightweight, modular, and extensible caching library designed to provide in-memory and persistent caching mechanisms with configurable expiration and cleanup policies.
Features
- In-Memory Cache: High-performance caching for frequently accessed data.
- Persistent Cache: Optional persistent storage with SQLite support.
- Expiration Policies: Configurable item expiration times.
- Background Cleanup: Periodic removal of expired items for optimal memory usage.
- Metrics: Tracks cache hits, misses, and overall performance.
Installation
Cachey is distributed as a .NET library. To install, use the NuGet package manager:
dotnet add package Cachey
Usage
Basic Setup
To start using Cachey, initialize an instance of the Cache class:
var cache = new Cache();
Adding and Retrieving Items
await cache.SetAsync("key", "value", TimeSpan.FromMinutes(5));
var value = await cache.GetAsync<string>("key");
Checking for Existence
bool exists = await cache.ContainsAsync("key");
Removing Items
await cache.RemoveAsync("key");
Clearing the Cache
await cache.ClearAsync();
Background Cleanup Service
Cachey includes a background cleanup service to remove expired items automatically. You can configure and start it as follows:
var cleanupService = new BackgroundCleanupService(cache, TimeSpan.FromSeconds(30));
cleanupService.Start();
Metrics
Metrics provide insights into cache performance:
var metrics = cache.GetMetrics();
Console.WriteLine($"Hits: {metrics.Hits}, Misses: {metrics.Misses}");
Persistent Caching
To enable persistent caching with SQLite:
Add the
Cachey.Persistence.SQLitepackage:dotnet add package Cachey.Persistence.SQLiteUse the
SqliteCacheRepository:var options = new DbContextOptionsBuilder<CacheyDbContext>() .UseSqlite("Data Source=cachey.db") .Options; var context = new CacheyDbContext(options); var persistentCache = new SqliteCacheRepository(context); var cache = new Cache(persistentCache);
Testing
Cachey includes a suite of tests to ensure reliability. To run the tests, use:
dotnet test
Contributions
Contributions are welcome! Feel free to submit issues or pull requests on the GitHub repository.
License
Cachey is licensed under the MIT License. See the LICENSE file for more details.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net9.0
- Cachey.Common (>= 1.0.2)
- Microsoft.EntityFrameworkCore.Sqlite (>= 9.0.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Cachey.Persistence.SQLite:
| Package | Downloads |
|---|---|
|
Cachey.Core
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.