assistant.net.storage
0.5.182
dotnet add package assistant.net.storage --version 0.5.182
NuGet\Install-Package assistant.net.storage -Version 0.5.182
<PackageReference Include="assistant.net.storage" Version="0.5.182" />
paket add assistant.net.storage --version 0.5.182
#r "nuget: assistant.net.storage, 0.5.182"
// Install assistant.net.storage as a Cake Addin #addin nuget:?package=assistant.net.storage&version=0.5.182 // Install assistant.net.storage as a Cake Tool #tool nuget:?package=assistant.net.storage&version=0.5.182
assistant.net.storage
Basic key-value based storage implementation designed to be easily extended and flexibly configured. It gives an opportunity to isolate an application from specific data store provider.
Default configuration
To add storage one of methods should be called:
var services = new ServiceCollection()
.AddStorage(b => ...) // adds dependencies and initial configuration
.ConfigureStorage(b => ...); // appends existing configuration (no dependencies are added)
where a specific provider should be selected for the storing data
services.ConfigureStorage(b => b.UseLocal()); // mongo or other
and key-value types allowed for storing
services.ConfigureStorage(b => b
.Add<SomeKey, SomeModel>() // by registering specific pairs
.AllowAnyType()); // or allowing any type
Configuration extension
Storage configuration may be big and complicated so applying it again and again can be annoying and error-prone. But message configuration can help to avoid that
services.ConfigureStorage(b => b
.AddConfiguration<CustomStorageConfiguration>() // by a type parameter
.AddConfiguration(new CustomStorageConfiguration())); // or an instance
public class CustomStorageConfiguration : IStorageConfiguration { ... }
Named configuration
Storage implementation is based on named options so you can have multiple named storages with different configurations.
var provider = new ServiceCollection()
.AddStorage()
.ConfigureStorage("name-1", o => o.UseLocal().Add<int, ModelOne>())
.ConfigureStorage("name-2", o => o.UseMongo().Add<string, ModelTwo>())
.BuildServiceProvider();
using var scope1 = provider.CreateScopeWithNamedOptionContext("name-1");
using var scope2 = provider.CreateScopeWithNamedOptionContext("name-2");
var storage1 = scope1.ServiceProvider.GetRequiredService<IStorage<int, ModelOne>>();
var storage2 = scope2.ServiceProvider.GetRequiredService<IStorage<string, ModelTwo>>();
Storage resolving
Once storage was properly configured a specific storages can be resolved
var storage = provider.GetRequiredService<IStorage<Key, SomeModel>>();
var historicalStorage = provider.GetRequiredService<IHistoricalStorage<Key, SomeModel>>();
var partitionedStorage = provider.GetRequiredService<IPartitionedStorage<Key, SomeModel>>();
or specific storages extended with operations like removing values, getting value details or stored keys
var regularAdminStorage = provider.GetRequiredService<IAdminStorage<Key, SomeModel>>();
var historicalAdminStorage = provider.GetRequiredService<IHistoricalAdminStorage<Key, SomeModel>>();
var partitionedAdminStorage = provider.GetRequiredService<IPartitionedAdminStorage<Key, SomeModel>>();
Pay attention, if specific storage isn't properly configured, resolving it will throw an exception.
Available providers
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net7.0 is compatible. 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. |
-
net7.0
- assistant.net.core (>= 0.5.182)
- assistant.net.diagnostics (>= 0.5.182)
- assistant.net.serialization.json (>= 0.5.182)
- Microsoft.Extensions.Diagnostics.HealthChecks (>= 7.0.5)
NuGet packages (5)
Showing the top 5 NuGet packages that depend on assistant.net.storage:
Package | Downloads |
---|---|
assistant.net.messaging
Local (in-memory) message handling implementation. |
|
assistant.net.storage.mongo
A MongoDB based storage implementation. |
|
assistant.net.messaging.generic.client
Storage based message handling client. |
|
assistant.net.storage.sqlite
An SQLite based storage implementation. |
|
assistant.net.messaging.generic.server
storage based message handling server. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
0.5.182 | 791 | 5/8/2023 |
0.4.151 | 813 | 3/28/2023 |
0.4.145 | 873 | 3/22/2023 |
0.4.144 | 2,322 | 9/4/2022 |
0.4.140 | 2,343 | 8/13/2022 |
0.3.139 | 2,342 | 8/9/2022 |
0.3.138 | 2,309 | 8/7/2022 |
0.3.137 | 2,318 | 8/6/2022 |
0.3.135 | 2,140 | 7/14/2022 |
0.3.133 | 2,176 | 7/4/2022 |
0.3.127 | 2,156 | 6/26/2022 |
0.3.125 | 2,157 | 6/25/2022 |
0.3.123 | 2,248 | 6/23/2022 |
0.3.121 | 2,212 | 6/22/2022 |
0.3.119 | 2,148 | 6/20/2022 |