您的位置:首頁技術文章
文章詳情頁

為什么redis中incr一個“0” 會報錯?

瀏覽:86日期:2024-07-09 14:21:08

問題描述

為什么redis中incr一個“0” 會報錯?

問下 弄過redis的人 為什么incr命令會報錯。?!?”可以轉換為 0 呀。

redis 版本是windows 3.2.100 穩定版

問題解答

回答1:

我這邊也是正常的

127.0.0.1:6379> set test '0'OK127.0.0.1:6379> INCR test(integer) 1127.0.0.1:6379> INCR test(integer) 2127.0.0.1:6379> INCR test(integer) 3127.0.0.1:6379> get test'3'127.0.0.1:6379> type teststring

版本是redis-3.2.4

回答2:

incr

# 情況3:key不是數字值redis> SET book 'long long ago...'OKredis> INCRBY book 200(error) ERR value is not an integer or out of range

不知道你的版本是多少,我版本redis_version:2.4.10 測試沒問題的,在線測試鏈接

回答3:

ServiceStack.Redis 客戶端 的確是為string類型的值省略了“”。如果額外加上“” 反而弄巧成拙了! 另外多謝 @蘇生不惑 @mylxsw

相關文章:
国产综合久久一区二区三区