示例#1
0
 public override void Transaction()
 {
     using (var tran = RedisManager.GetClient().CreateTransaction())
     {
         try
         {
             tran.QueueCommand(p =>
             {
                 //操作redis数据命令
                 RedisCacheStrategy.redisClient.Set <int>("name", 30);
                 long i = RedisCacheStrategy.redisClient.IncrementValueBy("name", 1);
             });
             //提交事务
             tran.Commit();
         }
         catch
         {
             //回滚事务
             tran.Rollback();
         }
     }
 }
 public RedisCacheStrategy()
 {
     redisClient = RedisManager.GetClient();
 }