> multi OK > set key1 1 QUEUED > set key2 2 QUEUED > get key2 QUEUED > exec OK OK 2
异常
编译时异常
命令有问题,事务所有的命令都不会被执行
1 2 3 4 5 6 7 8 9 10 11 12 13 14
> flushdb OK > multi OK > set key1 1 QUEUED > set key2 #错误命令 QUEUED > exec EXECABORT Transaction discarded because of previous errors. #执行事务报错 > get key2 null > get key1 #所有命令都不会被执行 null
> flushdb OK > set k1 abc OK > multi OK > set k2 2 QUEUED > incr k2 QUEUED > incr k1 #k1为字符串,无法加1 QUEUED > get k1 QUEUED > get k2 QUEUED > exec 1) OK 2) (integer) 3 3) (error) ERR value is not an integer or out of range # incr k1执行报错 4) "abc" 5) "3" > get k2 #其他命令正常执行 "3"
> set money 100 OK > set usedMoney 0 OK > watch money #监视money对象 OK > multi OK > decrby money 20 QUEUED > incrby usedMoney 20 QUEUED > exec#事务正常结束,数据期间没有发生变动,这时候事务正常执行 80 20 > get money 80
> set money 100 OK > set usedMoney 0 OK > watch money #监视money OK > multi OK > decrby money 20 QUEUED > incrby usedMoney 20 QUEUED > exec#执行之前,其他客户端执行 set money 10 null #对比watch监控的money,发生变化,修改失败
> unwatch #执行失败,就先解锁 OK > watch money #获取最新值,再次监控(此时money=10,usedMoney=0) OK > multi OK > decrby money 5 QUEUED > incrby usedMoney 5 QUEUED > exec 5 5 > get money 5 > get usedMoney 5
# debug (a lot of information, useful for development/testing) # verbose (many rarely useful info, but not a mess like the debug level) # notice (moderately verbose, what you want in production probably) # warning (only very important / critical messages are logged) loglevel notice #日志级别
SNAPSHOTTING快照模块 #达到已下条件,就进行保存 save 900 1 #15分钟内改了1次。 save 300 10 #5分钟内改了10次, save 60 10000 #1分钟内改了1万次, #如果想禁用RDB持久化的策略,只要不设置任何save指令,或者给save传入一个空字符串参数也可以 save ""
LIMITS限制模块 # maxclients 10000 #设置redis同时可以与多少个客户端进行连接。默认情况下为10000个客户端。当你无法设置进程文件句柄限制时,redis会设置为当前的文件句柄限制值减去32,因为redis会为自身内部处理逻辑留一些句柄出来。如果达到了此限制,redis则会拒绝新的连接请求,并且向这些连接请求方发出“max number of clients reached”以作回应。