private IDistributedCache GetSqlServerCache(SqlServerCacheOptions options = null)
        {
            if (options == null)
            {
                options = GetCacheOptions();
            }

            return(new SqlServerCache(options));
        }
        public static void UseSqlServer(
            this ConcurrencyOptionsBuilder concurrencyOptionsBuilder,
            Action<SqlServerCacheOptions> callback)
        {
            if (callback == null)
            {
                throw new ArgumentNullException(nameof(callback));
            }

            var options = new SqlServerCacheOptions();
            callback(options);
            UseSqlServer(concurrencyOptionsBuilder, options);
        }
        private SqlServerCache GetCache(ISystemClock testClock = null)
        {
            var options = new SqlServerCacheOptions()
            {
                ConnectionString             = _connectionString,
                SchemaName                   = _schemaName,
                TableName                    = _tableName,
                SystemClock                  = testClock ?? new TestClock(),
                ExpiredItemsDeletionInterval = TimeSpan.FromHours(2)
            };

            return(new SqlServerCache(new TestSqlServerCacheOptions(options)));
        }
        public SqlServerStorage(SqlServerCacheOptions options)
        {
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            var builder = new ServiceCollection();
            builder.AddSingleton<IDistributedCache>(serviceProvider =>
            new SqlServerCache(Options.Create(options)));
            var provider = builder.BuildServiceProvider();
            Initialize((IDistributedCache)provider.GetService(typeof(IDistributedCache)));
        }
        public static void UseSqlServer(
            this ConcurrencyOptionsBuilder concurrencyOptionsBuilder,
            SqlServerCacheOptions options)
        {
            if (concurrencyOptionsBuilder == null)
            {
                throw new ArgumentNullException(nameof(concurrencyOptionsBuilder));
            }

            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            concurrencyOptionsBuilder.ConcurrencyOptions.Storage = new SqlServerStorage(options);
        }
        private async Task <SqlServerCache> GetCacheAndConnectAsync(ISystemClock testClock = null)
        {
            var options = new SqlServerCacheOptions()
            {
                ConnectionString             = _connectionString,
                SchemaName                   = _schemaName,
                TableName                    = _tableName,
                SystemClock                  = testClock ?? new TestClock(),
                ExpiredItemsDeletionInterval = TimeSpan.FromHours(2)
            };

            var cache = new SqlServerCache(new TestSqlServerCacheOptions(options));

            await cache.ConnectAsync();

            return(cache);
        }