Esempio n. 1
0
        private static void UseClient(IRedisClientManager manager, int clientNo)
        {
            using (var client = manager.GetReadOnlyClient()) {
                lock (_hostCountMap) {
                    if (!_hostCountMap.TryGetValue(client.Host, out var hostCount))
                    {
                        hostCount = 0;
                    }

                    _hostCountMap[client.Host] = ++hostCount;
                }

                Console.WriteLine("Client '{0}' is using '{1}'", clientNo, client.Host);
            }
        }
Esempio n. 2
0
        private static void AssertClientManager(IRedisClientManager redisManager, RedisEndpoint expected)
        {
            using (var readWrite = (RedisClient)redisManager.GetClient()) {
                using (var readOnly = (RedisClient)redisManager.GetReadOnlyClient()) {
                    using (var cacheClientWrapper = (RedisClientManagerCacheClient)redisManager.GetCacheClient()) {
                        AssertClient(readWrite, expected);
                        AssertClient(readOnly, expected);

                        using (var cacheClient = (RedisClient)cacheClientWrapper.GetClient()) {
                            AssertClient(cacheClient, expected);
                        }
                    }
                }
            }
        }
Esempio n. 3
0
        private static void InitializeEmptyRedisManagers(IRedisClientManager redisManager, string[] masters, string[] slaves)
        {
            var hasResolver = (IHasRedisResolver)redisManager;

            hasResolver.RedisResolver.ResetMasters(masters);
            hasResolver.RedisResolver.ResetSlaves(slaves);

            using (var master = redisManager.GetClient()) {
                Assert.That(master.GetHostString(), Is.EqualTo(Config.Sentinel6380));
                master.SetValue("KEY", "1");
            }

            using (var slave = redisManager.GetReadOnlyClient()) {
                Assert.That(slave.GetHostString(), Is.EqualTo(Config.Sentinel6380).Or.EqualTo(Config.Sentinel6381));
                Assert.That(slave.GetValue("KEY"), Is.EqualTo("1"));
            }
        }
Esempio n. 4
0
 private static void UseClientAsync(IRedisClientManager manager, int clientNo, string testData)
 {
     using (var client = manager.GetReadOnlyClient()) {
         UseClient(client, clientNo, testData);
     }
 }