redis> SET totalNum 10
OK
redis> DECR totalNum //依次减一
(integer) 9
redis> SET totalNum 20
OK
redis> INCR totalNum //依次加一
(integer) 21
redis> GET totalNum # 数字值在 Redis 中以字符串的形式保存
"21"
127.0.0.1:6379> INCRBY num 100
(integer) 100
127.0.0.1:6379> INCRBY num 25 // 设置直接增加多少
(integer) 125
127.0.0.1:6379> DECRBY num 10 // 设置直接减少多少
(integer) 115
127.0.0.1:6379> DECRBY num 50
(integer) 65
本文介绍了如何在Redis中进行数字的增加和减少操作,探讨了Redis作为轻量级数据库在处理简单计数场景下的高效性和实用性。

3336

被折叠的 条评论
为什么被折叠?



