Proxfield.Extensions.Caching.SQLite.DependencyInjection
2.0.0
dotnet add package Proxfield.Extensions.Caching.SQLite.DependencyInjection --version 2.0.0
NuGet\Install-Package Proxfield.Extensions.Caching.SQLite.DependencyInjection -Version 2.0.0
<PackageReference Include="Proxfield.Extensions.Caching.SQLite.DependencyInjection" Version="2.0.0" />
<PackageVersion Include="Proxfield.Extensions.Caching.SQLite.DependencyInjection" Version="2.0.0" />
<PackageReference Include="Proxfield.Extensions.Caching.SQLite.DependencyInjection" />
paket add Proxfield.Extensions.Caching.SQLite.DependencyInjection --version 2.0.0
#r "nuget: Proxfield.Extensions.Caching.SQLite.DependencyInjection, 2.0.0"
#:package Proxfield.Extensions.Caching.SQLite.DependencyInjection@2.0.0
#addin nuget:?package=Proxfield.Extensions.Caching.SQLite.DependencyInjection&version=2.0.0
#tool nuget:?package=Proxfield.Extensions.Caching.SQLite.DependencyInjection&version=2.0.0
<p align="center"> <img src="https://github.com/proxfield/Proxfield.Extensions.Caching.SQLite/assets/7343019/967483a9-c62e-4730-99a3-5f1b1aa0e358" alt="Proxfield.Extensions.Caching.SQLite Logo" /> </p>
Proxfield.Extensions.Caching.SQLite
The SQLite Caching Library is a layer for caching data on SQLite to be used as a secondary database in case of failures and network inconsistencies.
This library is based on Microsoft.Extensions.Caching.StackExchangeRedis for memory caching, but uses SQLite as the data store. It serves as a persistent cache layer, leveraging Microsoft.Data.Sqlite.
Packages
Packages and versions available at the Nuget Gallery.
| Package | Version | Downloads |
|---|---|---|
| Proxfield.Extensions.Caching.SQLite | ||
| Proxfield.Extensions.Caching.SQLite.DependencyInjection |
Installation
PM> Install-Package Proxfield.Extensions.Caching.SQLite
For applications using Microsoft.Extensions.DependencyInjection, use the DI package:
PM> Install-Package Proxfield.Extensions.Caching.SQLite.DependencyInjection
Visit the Nuget Repository Page to learn more.
Usage
Initialization can be done via standard instantiation or through Dependency Injection.
Common Initialization
var cache = new SQLiteCache(options =>
{
options.Location = @"c:\cache\database.sqlite";
});
Dependency Injection Initialization
services.AddSQLiteCache(options => {
options.Location = @"c:\cache\database.sqlite";
});
Configuration
Database File Location
If options.Location is not provided, the database will be stored in the same folder as the running application.
Encryption
To enable data encryption, set UseEncryption to true and provide an EncryptionKey:
services.AddSQLiteCache(options => {
options.UseEncryption = true;
options.EncryptionKey = "d5644e8105ad77c3c3324ba693e83d8f";
});
Caching Methods
Data can be stored/retrieved as simple strings or complex objects.
Basic Usage
// Store as string
this.cache.SetAsString("users/1", "jose");
var userName = this.cache.GetAsString("users/1");
// Store as object
this.cache.SetAsObject<User>("users/1", new User() { Name = "Jose" });
var user = this.cache.GetAsObject<User>("users/1");
Available Methods
| Method | Description |
|---|---|
byte[] Get(string key) |
Retrieves a cached resource from the database. |
Task<byte[]> GetAsync(string key) |
Retrieves a cached resource asynchronously. |
void Set(string key, byte[] value) |
Sets a cached resource in the database. |
Task SetAsync(string key, byte[] value) |
Sets a cached resource asynchronously. |
void Remove(string key) |
Removes a cached resource from the database. |
Task RemoveAsync(string key) |
Removes a cached resource asynchronously. |
void SetAsString(string key, string value) |
Sets a string in the database. |
Task SetAsStringAsync(string key, string value, CancellationToken token = default) |
Sets a string in the database asynchronously. |
void SetAsObject<T>(string key, T value) |
Sets an object in the database. |
Task SetAsObjectAsync<T>(string key, T value, CancellationToken token = default) |
Sets an object in the database asynchronously. |
string GetAsString(string key) |
Retrieves a string from the database. |
Task<string> GetAsStringAsync(string key, CancellationToken token = default) |
Retrieves a string from the database asynchronously. |
T? GetAsObject<T>(string key) |
Retrieves an object from the database. |
Task<T?> GetAsObjectAsync<T>(string key, CancellationToken token = default) |
Retrieves an object from the database asynchronously. |
List<T> GetAsObjectStartsWith<T>(string key, int start = 0, int pageSize = int.MaxValue) |
Gets a list of objects where the key starts with the specified string. |
Task<List<T>?> GetAsObjectStartsWithAsync<T>(string key, int start = 0, int pageSize = int.MaxValue, CancellationToken token = default) |
Gets a list of objects where the key starts with the specified string asynchronously. |
List<string> GetAsStringStartsWith(string key, int start = 0, int pageSize = int.MaxValue) |
Gets a list of strings where the key starts with the specified string. |
Task<List<string>?> GetAsStringStartsWithAsync(string key, int start = 0, int pageSize = int.MaxValue, CancellationToken token = default) |
Gets a list of strings where the key starts with the specified string asynchronously. |
void ClearCache() |
Clears all items from the cache (excluding indexes). |
Task ClearCacheAsync(CancellationToken token = default) |
Clears all items from the cache asynchronously. |
Collections and Indexes
You can index cached objects/strings. For example, saving an object with key vehicles/1:
cache.SetAsObject("vehicles/1", new { Name = "bicycle" });
This makes it possible to query multiple objects at once (e.g., every document in a collection):
cache.GetAsObjectStartsWith<Vehicle>("vehicles");
Index Management Methods
Accessed via cache.Maintenance.
| Method | Description |
|---|---|
List<SQLiteCacheIndex> GetAllIndexes() |
Returns all indexes in the database. |
SQLiteCacheIndex? GetIndex(string name) |
Returns a specific index. |
void ClearAllIndexers() |
Purges all indexes from the database. |
void ResetIndex(string name, long? value = null) |
Resets an index to a specific value. |
Platform Support
SQLite Caching is compiled for:
- .NET 6
- .NET 5
- .NET Core 3.1
License
The MIT License (MIT) - Copyright (c) 2022-2026 Proxfield Consulting Group and its affiliates.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 is compatible. net5.0-windows was computed. net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. 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. net9.0 was computed. 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. |
| .NET Core | netcoreapp3.1 is compatible. |
-
.NETCoreApp 3.1
- Microsoft.Extensions.DependencyInjection (>= 6.0.0)
- Proxfield.Extensions.Caching.SQLite (>= 2.0.0)
-
net5.0
- Microsoft.Extensions.DependencyInjection (>= 6.0.0)
- Proxfield.Extensions.Caching.SQLite (>= 2.0.0)
-
net6.0
- Microsoft.Extensions.DependencyInjection (>= 6.0.0)
- Proxfield.Extensions.Caching.SQLite (>= 2.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 |
|---|---|---|
| 2.0.0 | 439 | 12/8/2025 |
| 1.1.3 | 322 | 8/10/2023 |
| 1.1.2 | 302 | 7/22/2023 |
| 1.1.1 | 257 | 7/22/2023 |
| 1.1.0 | 262 | 7/22/2023 |
| 1.0.4 | 632 | 9/22/2022 |
| 1.0.3 | 576 | 8/3/2022 |
| 1.0.2 | 561 | 8/3/2022 |
| 1.0.1 | 558 | 8/3/2022 |
| 1.0.0 | 543 | 8/2/2022 |
| 0.3.4 | 566 | 7/29/2022 |
| 0.3.3 | 568 | 7/29/2022 |
| 0.3.2 | 590 | 7/20/2022 |
| 0.3.1 | 567 | 7/20/2022 |
| 0.3.0 | 595 | 7/20/2022 |
| 0.2.6 | 630 | 7/13/2022 |
| 0.2.5 | 633 | 7/13/2022 |
| 0.2.4 | 609 | 7/13/2022 |
| 0.2.3 | 602 | 7/12/2022 |
| 0.2.2 | 600 | 7/12/2022 |