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                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="assistant.net.storage" Version="0.5.182" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add assistant.net.storage --version 0.5.182                
#r "nuget: assistant.net.storage, 0.5.182"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// 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

  • Local provider (in-memory, available out of box),
  • MongoDb,
  • SQLite.
Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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 792 5/8/2023
0.4.151 814 3/28/2023
0.4.145 874 3/22/2023
0.4.144 2,323 9/4/2022
0.4.140 2,343 8/13/2022
0.3.139 2,343 8/9/2022
0.3.138 2,310 8/7/2022
0.3.137 2,319 8/6/2022
0.3.135 2,141 7/14/2022
0.3.133 2,176 7/4/2022
0.3.127 2,157 6/26/2022
0.3.125 2,158 6/25/2022
0.3.123 2,249 6/23/2022
0.3.121 2,213 6/22/2022
0.3.119 2,148 6/20/2022