为什么redis中incr一个“0” 会报错?
过去多啦不再A梦
过去多啦不再A梦 2017-04-27 09:02:55
0
3
927

问下 弄过redis的人 为什么incr命令会报错。。“0”可以转换为 0 呀。

redis 版本是windows 3.2.100 稳定版

过去多啦不再A梦
过去多啦不再A梦

reply all(3)
为情所困

It’s normal here too

127.0.0.1:6379> set test "0"
OK
127.0.0.1:6379> INCR test
(integer) 1
127.0.0.1:6379> INCR test
(integer) 2
127.0.0.1:6379> INCR test
(integer) 3
127.0.0.1:6379> get test
"3"
127.0.0.1:6379> type test
string

The version is redis-3.2.4

左手右手慢动作

incr

# 情况3:key不是数字值

redis> SET book "long long ago..."
OK

redis> INCRBY book 200
(error) ERR value is not an integer or out of range

I don’t know what your version is. My version is redis_version:2.4.10. The test is fine. Online test link

左手右手慢动作

ServiceStack.Redis client indeed omits "" for string type values. If you add an extra "", it will be self-defeating! Also, thank you
@苏生Buhuo @mylxsw

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template