public void Redis_UseExistingConnection()
        {
            var conConfig = new ConfigurationOptions()
            {
                ConnectTimeout     = 10000,
                AbortOnConnectFail = false,
                ConnectRetry       = 10
            };

            conConfig.EndPoints.Add("localhost:6379");

            var multiplexer = ConnectionMultiplexer.Connect(conConfig);

            var cfg = ConfigurationBuilder.BuildConfiguration(
                s => s
                .WithJsonSerializer()
                .WithRedisConfiguration("redisKey", multiplexer)
                .WithRedisCacheHandle("redisKey"));

            RedisConnectionManager.RemoveConnection(multiplexer.Configuration);

            using (multiplexer)
                using (var cache = new BaseCacheManager <long>(cfg))
                {
                    cache.Add(Guid.NewGuid().ToString(), 12345);
                }
        }
        public async Task Redis_ValidateVersion_AddPutGetUpdate()
        {
            var configKey = Guid.NewGuid().ToString();
            var multi     = ConnectionMultiplexer.Connect("localhost");
            var cache     = CacheFactory.Build <Poco>(
                s => s
                .WithRedisConfiguration(configKey, multi)
                .WithBondCompactBinarySerializer()
                .WithRedisCacheHandle(configKey));

            // don't keep it and also dispose it later (seems appveyor doesn't like too many open connections)
            RedisConnectionManager.RemoveConnection(multi.Configuration);

            // act/assert
            using (multi)
                using (cache)
                {
                    var key   = Guid.NewGuid().ToString();
                    var value = new Poco()
                    {
                        Id = 23, Something = "§asdad"
                    };
                    cache.Add(key, value);
                    await Task.Delay(10);

                    var version = (int)multi.GetDatabase(0).HashGet(key, "version");
                    version.Should().Be(1);

                    cache.Put(key, value);
                    await Task.Delay(10);

                    version = (int)multi.GetDatabase(0).HashGet(key, "version");
                    version.Should().Be(2);

                    cache.Update(key, r => { r.Something = "new text"; return(r); });
                    await Task.Delay(10);

                    version = (int)multi.GetDatabase(0).HashGet(key, "version");
                    version.Should().Be(3);
                    cache.Get(key).Something.Should().Be("new text");
                }
        }
        public void Redis_Extensions_WithClientWithDb()
        {
            var configKey = Guid.NewGuid().ToString();
            var client    = ConnectionMultiplexer.Connect("localhost");
            var cache     = CacheFactory.Build <string>(
                s => s
                .WithJsonSerializer()
                .WithRedisConfiguration(configKey, client, 23)
                .WithRedisCacheHandle(configKey));

            var handle = cache.CacheHandles.OfType <RedisCacheHandle <string> >().First();
            var cfg    = RedisConfigurations.GetConfiguration(configKey);

            Assert.Equal(handle.Configuration.Name, configKey);
            Assert.Equal(23, cfg.Database);
            Assert.Equal("localhost:6379", cfg.ConnectionString);

            // cleanup
            RedisConnectionManager.RemoveConnection(client.Configuration);
            client.Dispose();
        }