JGUZDV.ClientStorage
1.1.0
dotnet add package JGUZDV.ClientStorage --version 1.1.0
NuGet\Install-Package JGUZDV.ClientStorage -Version 1.1.0
<PackageReference Include="JGUZDV.ClientStorage" Version="1.1.0" />
<PackageVersion Include="JGUZDV.ClientStorage" Version="1.1.0" />
<PackageReference Include="JGUZDV.ClientStorage" />
paket add JGUZDV.ClientStorage --version 1.1.0
#r "nuget: JGUZDV.ClientStorage, 1.1.0"
#:package JGUZDV.ClientStorage@1.1.0
#addin nuget:?package=JGUZDV.ClientStorage&version=1.1.0
#tool nuget:?package=JGUZDV.ClientStorage&version=1.1.0
JGUZDV.ClientStorage
Simple caching and storage solution with optional background refreshs.
Setup
To use the ClientStorage you need an implementation of IMemoryCache, IKeyValueStorage and ILifeCycleEvents.
Using the Storage
//use DI
services.AddScoped<ClientStorage>();
//or new one up
var store = new ClientStorage(...);
Registration
You can register an entry like so
store.Register("testKey", new StoreOptions<string>
{
LoadFunc = GetTestData, // function which returns the value
UsesBackgroundRefresh = false, // configure if entry should be refreshed automatically
ValueExpiry = TimeSpan.FromMinutes(10) // configure expiry time
});
and unregister
store.Unregister("testKey");
Retrieval
You can load an entry
var entry = await store.GetEntry<string>("testKey");
you can also load the value directly
var value = await store.Get<string>("testKey");
Combining registration and retrieval
you can also combine loading and registration like this
var entry = await store.GetOrLoadEntry("schedule", new StoreOptions<Schedule>
{
ValueExpiry = _defaultExpiry,
LoadFunc = (ct) => _scheduleService.GetSchedule(ct),
UsesBackgroundRefresh = true
})
and you can also load the value directly
var value = await store.GetOrLoad("schedule", new StoreOptions<Schedule>
{
ValueExpiry = _defaultExpiry,
LoadFunc = (ct) => _scheduleService.GetSchedule(ct),
UsesBackgroundRefresh = true
})
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. 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. |
-
net10.0
- Microsoft.Extensions.Caching.Abstractions (>= 10.0.14)
- Microsoft.Extensions.Caching.Memory (>= 10.0.14)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.14)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on JGUZDV.ClientStorage:
| Package | Downloads |
|---|---|
|
JGUZDV.JobHost.Dashboard.Blazor
Blazor components of Dashboard for JGUZDV.JobHost package. |
|
|
JGUZDV.ClientStorage.Blazor
Blazor extensions for client storage |
GitHub repositories
This package is not used by any popular GitHub repositories.