public static void AddRedbox(this IServiceCollection services, Action <RedboxOptions> configure) { if (configure == null) { throw new ArgumentNullException(nameof(configure)); } services.AddSingleton <IRedbox, Redbox>(); services.AddSingleton <IDispatcher, Dispatcher>(); services.AddSingleton <ICacheProxy, CacheProxy>(); services.TryAddEnumerable( new[] { ServiceDescriptor.Singleton <IWorker, KeyPostman>(), ServiceDescriptor.Singleton <IWorker, KeyRetrier>(), ServiceDescriptor.Singleton <IWorker, KeyCleaner>() }); var options = new RedboxOptions(); configure(options); options.Plugins.ForEach(plugin => plugin.Register(services)); services.Configure(configure); services.AddSingleton <IRedboxEntry, RedboxEntry>(); services.AddHostedService <RedboxEntry>(); }
public SqlServerKeyStorage( IOptions <SqlServerOptions> options, IOptions <RedboxOptions> redboxOptions, IStorageBoost storageBoost) { _options = options.Value; _redboxOptions = redboxOptions.Value; _boost = storageBoost; }
public Dispatcher( ILogger <Dispatcher> logger, IOptions <RedboxOptions> options, ICacheClientFactory cacheFactory) { _cts = new CancellationTokenSource(); _keysBuffer = Channel.CreateUnbounded <IEnumerable <string> >(); _logger = logger; _options = options.Value; _cacheFactory = cacheFactory; }
public static RedboxOptions UseRedis(this RedboxOptions options, Action <RedisOptions> configure) { options.RegisterPlugin(new RedisPlugin(configure)); return(options); }
public static RedboxOptions UseRedis(this RedboxOptions options) { options.RegisterPlugin(new RedisPlugin()); return(options); }
public static RedboxOptions UseSqlServer(this RedboxOptions options, Action <SqlServerOptions> configure) { options.RegisterPlugin(new SqlServerPlugin(configure)); return(options); }
public static RedboxOptions UseSqlServer(this RedboxOptions options) { options.RegisterPlugin(new SqlServerPlugin()); return(options); }