public static void ExecTrans(this IRedisClientManager redisManager, Action <IRedisTransaction> lambda)
        {
            using (var redis = redisManager.GetClient()) {
                using (var trans = redis.CreateTransaction()) {
                    lambda(trans);

                    trans.Commit();
                }
            }
        }
Example #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);
                        }
                    }
                }
            }
        }
Example #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"));
            }
        }
Example #4
0
 protected RedisClient GetRedisClient(object shardObject, bool writable = true)
 {
     return(ClientManager.GetClient(shardObject, writable));
 }
 public static T ExecAs <T>(this IRedisClientManager redisManager, Func <IRedisTypedClient <T>, T> lambda)
 {
     using (var redis = redisManager.GetClient()) {
         return(lambda(redis.As <T>()));
     }
 }
 public static void ExecAs <T>(this IRedisClientManager redisManager, Action <IRedisTypedClient <T> > lambda)
 {
     using (var redis = redisManager.GetClient()) {
         lambda(redis.As <T>());
     }
 }
 public static bool Exec(this IRedisClientManager redisManager, Func <IRedisClient, bool> lambda)
 {
     using (var redis = redisManager.GetClient()) {
         return(lambda(redis));
     }
 }
 public static void Exec(this IRedisClientManager redisManager, Action <IRedisClient> lambda)
 {
     using (var redis = redisManager.GetClient()) {
         lambda(redis);
     }
 }
 private static void UseClientAsync(IRedisClientManager manager, int clientNo)
 {
     using (var client = manager.GetClient()) {
         UseClient(client, clientNo);
     }
 }