private void Commit(CSRedis.CSRedisClient redis, Action <RedisWriteOnlyTransaction> action)
 {
     using (var transaction = new RedisWriteOnlyTransaction(_storage))
     {
         action(transaction);
         transaction.Commit();
     }
 }
Пример #2
0
 private static void Commit(IRedisClient redis, Action <RedisWriteOnlyTransaction> action)
 {
     using (var transaction = new RedisWriteOnlyTransaction(redis.CreateTransaction()))
     {
         action(transaction);
         transaction.Commit();
     }
 }
 private void Commit(IDatabase connection, Action <RedisWriteOnlyTransaction> action)
 {
     using (var transaction = new RedisWriteOnlyTransaction(connection.CreateTransaction(), Redis.Storage.GetSubscribe(), Prefix))
     {
         action(transaction);
         transaction.Commit();
     }
 }
Пример #4
0
 private void Commit(IDatabase redis, Action <RedisWriteOnlyTransaction> action)
 {
     using (var transaction = new RedisWriteOnlyTransaction(_storage, redis.CreateTransaction()))
     {
         action(transaction);
         transaction.Commit();
     }
 }
 private void DifferentPrefix()
 {
     UseConnection(redis =>
     {
         var SecondStorage = new RedisStorage(Redis.ServerInfo, new RedisStorageOptions {
             Db = Redis.Storage.Db, Prefix = "test:"
         });
         var SecondConnection = SecondStorage.GetDatabase();
         Commit(redis, x => x.InsertToList("some-list", "value"));
         var transaction = new RedisWriteOnlyTransaction(SecondConnection.CreateTransaction(), SecondStorage.GetSubscribe(), SecondStorage.Prefix);
         transaction.InsertToList("some-list", "value2");
         transaction.Commit();
         Assert.Equal(1, redis.ListLength(Prefix + "some-list"));
         Assert.Equal(1, SecondConnection.ListLength(SecondStorage.Prefix + "some-list"));
         Assert.Equal("value", redis.ListLeftPop(Prefix + "some-list"));
         Assert.Equal("value2", SecondConnection.ListLeftPop(SecondStorage.Prefix + "some-list"));
     });
 }
 private static void Commit(IDatabase redis, Action<RedisWriteOnlyTransaction> action)
 {
     using (var transaction = new RedisWriteOnlyTransaction(redis.CreateTransaction()))
     {
         action(transaction);
         transaction.Commit();
     }
 }
 private void Commit(IDatabase connection, Action<RedisWriteOnlyTransaction> action)
 {
     using (var transaction = new RedisWriteOnlyTransaction(connection.CreateTransaction(), Redis.Storage.GetSubscribe(), Prefix))
     {
         action(transaction);
         transaction.Commit();
     }
 }
 private void DifferentPrefix()
 {
     UseConnection(redis =>
     {
         var SecondStorage = new RedisStorage(Redis.ServerInfo, new RedisStorageOptions { Db = Redis.Storage.Db, Prefix = "test:" });
         var SecondConnection = SecondStorage.GetDatabase();
         Commit(redis, x => x.InsertToList("some-list", "value"));
         var transaction = new RedisWriteOnlyTransaction(SecondConnection.CreateTransaction(), SecondStorage.GetSubscribe(), SecondStorage.Prefix);
         transaction.InsertToList("some-list", "value2");
         transaction.Commit();
         Assert.Equal(1, redis.ListLength(Prefix + "some-list"));
         Assert.Equal(1, SecondConnection.ListLength(SecondStorage.Prefix + "some-list"));
         Assert.Equal("value", redis.ListLeftPop(Prefix + "some-list"));
         Assert.Equal("value2", SecondConnection.ListLeftPop(SecondStorage.Prefix + "some-list"));
     });
 }