您好,登錄后才能下訂單哦!
1,set key value ex秒數/px 毫秒 nx/xx
127.0.0.1:6379> set name z2 px 1000
OK
127.0.0.1:6379> ttl name
(integer) -2
nx:表示key不存在時執行操作
xx:表示key存在時操作
如:
127.0.0.1:6379> flushdb
OK
127.0.0.1:6379> set jiaxiao dfss
OK
127.0.0.1:6379> set jiaxiao gjjx nx
(nil)
127.0.0.1:6379> get jiaxiao
"dfss"
127.0.0.1:6379> set jiaxiao hdjx xx
OK
127.0.0.1:6379> get jiaxiao
"hdjx"
2,get key
獲取鍵值
3,獲取多個key
mget key
4,偏移字符value
127.0.0.1:6379> set suixingpay niubi
OK
127.0.0.1:6379> get suixingpay
"niubi"
127.0.0.1:6379> setrange suixingpay 2 ll
(integer) 5
127.0.0.1:6379> get suixingpay
"nilli"
注意:如果偏移>字符長度,該字符自動補0x00
127.0.0.1:6379> setrange suixingpay 6 c
(integer) 7
127.0.0.1:6379> get suixingpay
"nilli\x00c"
5,附加值
127.0.0.1:6379> append suixingpay @
(integer) 8
127.0.0.1:6379> get suixingpay
"nilli\x00c@"
6,獲取字符串中某個值的范圍
注意:對于字符串的下標,左數從0開始,右數從-1開始
127.0.0.1:6379> set area beijing
OK
127.0.0.1:6379> getrange area 2 5
"ijin"
127.0.0.1:6379> getrange area 0 -5
"bei"
7,增加或者減少
127.0.0.1:6379> set ages 20
OK
127.0.0.1:6379> get ages
"20"
127.0.0.1:6379> incr age
(integer) 1
127.0.0.1:6379> get ages
"20"
127.0.0.1:6379> incr ages
(integer) 21
127.0.0.1:6379> get ages
"21"
127.0.0.1:6379> decr ages
(integer) 20
127.0.0.1:6379> get ages
"20"
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。