Proxfield.Extensions.Caching.SQLite.DependencyInjection
1.0.2
See the version list below for details.
dotnet add package Proxfield.Extensions.Caching.SQLite.DependencyInjection --version 1.0.2
NuGet\Install-Package Proxfield.Extensions.Caching.SQLite.DependencyInjection -Version 1.0.2
<PackageReference Include="Proxfield.Extensions.Caching.SQLite.DependencyInjection" Version="1.0.2" />
paket add Proxfield.Extensions.Caching.SQLite.DependencyInjection --version 1.0.2
#r "nuget: Proxfield.Extensions.Caching.SQLite.DependencyInjection, 1.0.2"
// Install Proxfield.Extensions.Caching.SQLite.DependencyInjection as a Cake Addin #addin nuget:?package=Proxfield.Extensions.Caching.SQLite.DependencyInjection&version=1.0.2 // Install Proxfield.Extensions.Caching.SQLite.DependencyInjection as a Cake Tool #tool nuget:?package=Proxfield.Extensions.Caching.SQLite.DependencyInjection&version=1.0.2
<img src="docs\images\cache.png" />
The SQLite Caching Library is layer for caching data on SQLite to be used as a secondary database in case of failures and network inconsistences.
Packages
Packages and versions available at the Nuget Galery.
Package | Version | Downloads |
---|---|---|
<b>Proxfield.Extensions.Caching.SQLite</b> | ||
<b>Proxfield.Extensions.Caching.SQLite.DependencyInjection</b> |
Nuget
PM> Install-Package Proxfield.Extensions.Caching.SQLite
For application who uses Microsoft.Extensions.DependencyInjection there is a package available for using the library with DI:
PM> Install-Package Proxfield.Extensions.Caching.SQLite.DependencyInjection
Visit out project at the Nuget Repository Page to know more.
How
This caching library is based on the "Microsoft.Extensions.Caching.Redis" for memory caching, but instead of using Redis it uses the SQLite as a data layer. The ideia is to be a library for persistence cache in case of failures. This library uses the "Microsoft.Data" and acts as a layer above the SQLite.
Usage
The initialization can be either by using Microsoft's dependency injection or a common initialization.
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";
});
Cache Methods available
The caching can be recorded/retrieved as a simple string
this.cache.SetAsString("users/1", "jose");
var user = this.cache.GetAsString("users/1");
Or either as a complex object:
this.cache.SetAsObject<User>("users/1", new User() { Name = "Jose" });
var user = this.cache.GetAsObject<User>("users/1");
The following list constains all caching methods avaliable currently on the library.
Method | Description |
---|---|
byte[] Get(string key); | Retrieves a cached resource from the database |
Task<byte[]> GetAsync(string key); | Retrieves a cached resource from the database as async |
void Set(string key, byte[] value); | Sets a cached resource to the database |
Task SetAsync(string key, byte[] value); | Sets a cached resource to the database async |
void Remove(string key); | Removes a cached resource to the database |
Task RemoveAsync(string key); | Removes a cached resource to the database as async |
void SetAsString(string key, string value); | Sets an string into the the database |
void SetAsObject<T>(string key, T value); | Sets an object into the the database |
string GetAsString(string key); | Retrieves a string from the database |
T? GetAsObject<T>(string key); | Retrieves an object from the database |
List<T> GetAsObjectStartsWith<T>(this ISQLiteCache cache, string key) | Get a list of objects when the key starts with something |
List<string> GetAsStringStartsWith(this ISQLiteCache cache, string key) | Get a list of strings when the key starts with something |
Collections and Indexes
It is now possible to cache objects/strings by using an index, for example, the following code on a newly created database would save the object with the key as being <strong>vehicles/1</strong>.
cache.SetAsObject("vehicles|", new { Name = "bycicle" }) ;
Making possible to query more than one object at once, every document on a collection.
cache.GetAsObjectStartsWith<Vehicle>("vehicles");
The following list constains all indexing methods avaliable currently on the library. They can be acessed by the Maintenance property of cache (<strong>cache.Maintenance.</strong>)
Method | Description |
---|---|
List<SQLiteCacheIndex> GetAllIndexes() | Returns all indexes on the database |
SQLiteCacheIndex? GetIndex(string name | Returns an index from the database |
void ClearAllIndexers() | Purge all indexes from the database |
void ResetIndex(string name, long? value = null) | Reset an index to an specific value |
Platform Support
SQLite Caching is compiled for DotNet 6, soon there will versions available for other plataforms.
- DotNet 6
- DotNet 5
License
The MIT License (MIT) - Copyright (c) 2022 Proxfield
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | 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. |
-
net6.0
- Microsoft.Extensions.DependencyInjection (>= 6.0.0)
- Proxfield.Extensions.Caching.SQLite (>= 1.0.2)
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 |
---|---|---|
1.1.3 | 215 | 8/10/2023 |
1.1.2 | 209 | 7/22/2023 |
1.1.1 | 158 | 7/22/2023 |
1.1.0 | 183 | 7/22/2023 |
1.0.4 | 497 | 9/22/2022 |
1.0.3 | 443 | 8/3/2022 |
1.0.2 | 423 | 8/3/2022 |
1.0.1 | 418 | 8/3/2022 |
1.0.0 | 420 | 8/2/2022 |
0.3.4 | 431 | 7/29/2022 |
0.3.3 | 431 | 7/29/2022 |
0.3.2 | 458 | 7/20/2022 |
0.3.1 | 434 | 7/20/2022 |
0.3.0 | 457 | 7/20/2022 |
0.2.6 | 488 | 7/13/2022 |
0.2.5 | 499 | 7/13/2022 |
0.2.4 | 473 | 7/13/2022 |
0.2.3 | 463 | 7/12/2022 |
0.2.2 | 468 | 7/12/2022 |