public RedisDatabase(KeyValueDatabaseOptions <TKeyValueDbContext> options) { Check.NotNullOrWhiteSpace(options.ConnectionString, nameof(options.ConnectionString)); var endpoint = options.ConnectionString.ToRedisEndpoint(); _pooledRedisLite = new PooledRedisLite(endpoint.Host, endpoint.Port, db: (int)endpoint.Db); }
public static IServiceCollection AddKeyValueDbContext <TKeyValueDbContext>( this IServiceCollection serviceCollection, Action <KeyValueDbContextCreationOptions <TKeyValueDbContext> > builder = null) where TKeyValueDbContext : KeyValueDbContext <TKeyValueDbContext> { serviceCollection.TryAddSingleton <TKeyValueDbContext>(); serviceCollection.TryAddTransient <KeyValueDatabaseOptions <TKeyValueDbContext> >(factory => { var o = new KeyValueDatabaseOptions <TKeyValueDbContext>(); var name = ConnectionStringNameAttribute.GetConnStringName <TKeyValueDbContext>(); o.ConnectionString = factory.GetRequiredService <IConnectionStringResolver>().Resolve(name); return(o); }); var options = new KeyValueDbContextCreationOptions <TKeyValueDbContext>(serviceCollection); builder?.Invoke(options); return(serviceCollection); }
public SsdbDatabase(KeyValueDatabaseOptions <TKeyValueDbContext> options) : base(options) { }