复述中事务操作的命令有哪些

  介绍

小编给大家分享一下复述中事务操作的命令有哪些,希望大家阅读完这篇文章之后都有所收获、下面让我们一起去探讨吧!

命令

多与执行

<李>

命令行

127.0.0.1:6379>多   好吧   127.0.0.1:6379> incr 总   排队   127.0.0.1:6379> incr 兰   排队   127.0.0.1:6379>执行   1),(整数),2   2),(整数),2   127.0.0.1:6379> get 总   “2”;   127.0.0.1:6379> get 兰   “2“ <李>

生菜实例

,,,@Test   ,,,public  void  testMultiExec () {   ,,,,,,,RedisClient  client =, RedisClient.create(“复述://192.168.99.100:6379/0");   ,,,,,,,StatefulRedisConnection<字符串,String>, connection =, client.connect ();   ,,,,,,,RedisCommands<字符串,String>, syncCommands =, connection.sync ();      ,,,,,,,syncCommands.set (“hello",“1“);   ,,,,,,,syncCommands.set (“world",“2“);      ,,,,,,,syncCommands.multi ();   ,,,,,,,syncCommands.incr (“hello");   ,,,,,,,syncCommands.incr (“world");      ,,,,,,,//DefaultTransactionResult [wasRolledBack=false,结果=[1,,2,,1,,3,,1]]   ,,,,,,,TransactionResult  TransactionResult =, syncCommands.exec ();   ,,,,,,,System.out.println (transactionResult);   ,,,,,,,System.out.println (syncCommands.get (“hello"));   ,,,,,,,System.out.println (syncCommands.get (“world"));   ,,,}

部分执行

<李>

命令行

127.0.0.1:6379>多   好吧   127.0.0.1:6379> set  a ,你好   排队   127.0.0.1:6379> set  b 世界   排队   127.0.0.1:6379> incr    排队   127.0.0.1:6379> set  c 部分   排队   127.0.0.1:6379>执行   1),好吧   2),好吧   3),(错误),ERR  value  is  not  an  integer 或是out  of 范围   4),好吧   127.0.0.1:6379> get    “hello"   127.0.0.1:6379> get  b   “world"   127.0.0.1:6379> get  c   “part" <李>

生菜实例

,,,@Test   ,,,public  void  testMultiExecError () {   ,,,,,,,RedisClient  client =, RedisClient.create(“复述://192.168.99.100:6379/0");   ,,,,,,,StatefulRedisConnection<字符串,String>, connection =, client.connect ();   ,,,,,,,RedisCommands<字符串,String>, syncCommands =, connection.sync ();      ,,,,,,,syncCommands.multi ();   ,,,,,,,syncCommands.set (“a",“hello");   ,,,,,,,syncCommands.set (“b",“world");   ,,,,,,,syncCommands.incr (“a");   ,,,,,,,syncCommands.set (“c",“part");   ,,,,,,,//DefaultTransactionResult [wasRolledBack=false,结果=(好吧,,好的,,io.lettuce.core.RedisCommandExecutionException:, ERR  value  is  not  an  integer 或是out  of 范围,,好的,,1]]   ,,,,,,,TransactionResult  TransactionResult =, syncCommands.exec ();   ,,,,,,,System.out.println (transactionResult);   ,,,,,,,System.out.println (syncCommands.get (“a"));   ,,,,,,,System.out.println (syncCommands.get (“b"));   ,,,,,,,System.out.println (syncCommands.get (“c"));   ,,,}

多与丢弃

<李>

命令行

127.0.0.1:6379> set  sum  1   好吧   127.0.0.1:6379>多   好吧   127.0.0.1:6379> incr 总和   排队   127.0.0.1:6379>抛弃   好吧   127.0.0.1:6379> get 总和   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null

复述中事务操作的命令有哪些