Cache.Collections.Dynamic

Fast Relational DB scalable caching. Multiple DB loaders.


Keywords
fast, relational, cache, reactive, orm, sql, micro-orm
License
GPL-3.0
Install
Install-Package Cache.Collections.Dynamic -Version 0.2.1

Documentation

Cache.Collections

Relational data to stream

Cache.Collections has no DB specific implementation details, it works across all .NET ADO providers including SQL Server, Oracle, MySQL, PostgreSQL and more. In order to add support for a specific provider IDbConnectionFactory must be implemented and registered as a service.

Download

Cache.Collections Nuget

PM> Install-Package Cache.Collections

Quick Start

// Define Db ConnectionFactory
public class SqlServerConnectionFactory : IDbConnectionFactory
{
    private readonly IConfiguration _configuration;

    public SqlServerConnectionFactory(IConfiguration configuration)
    {
        this._configuration = configuration;
    }

    public IDbConnection CreateConnection() => new SqlConnection(this._configuration.GetConnectionString("DefaultConnection"));
}

// Define
[FullOnlyLoader(FullLoadTimeoutMs = 60000, CommandText = "SELECT * FROM test_sports")]
public class FullOnlyItem
{
    [Key]
    public int ID { get; set; }
    
    public string Name { get; set; }
}

// Register
public IServiceProvider ConfigureServices(IServiceCollection services)
{
    services.AddCacheCollections();
    services.AddSingleton<IDbConnectionFactory, SqlServerConnectionFactory>();
}

// Start
public void Configure(IApplicationBuilder app)
{
    app.ApplicationServices.StartCacheCollections();
}

// Use
public class MyClass
{
    private readonly ICacheCollection<int, FullOnlyItem> _cache;
    
    public MyClass(ICacheCollection<int, FullOnlyItem> cache)
    {
        this._cache = cache;
    }
}