1,set key value ex秒數(shù)/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不存在時(shí)執(zhí)行操作
xx:表示key存在時(shí)操作
創(chuàng)新互聯(lián)建站憑借專業(yè)的設(shè)計(jì)團(tuán)隊(duì)扎實(shí)的技術(shù)支持、優(yōu)質(zhì)高效的服務(wù)意識(shí)和豐厚的資源優(yōu)勢(shì),提供專業(yè)的網(wǎng)站策劃、成都網(wǎng)站建設(shè)、網(wǎng)站建設(shè)、網(wǎng)站優(yōu)化、軟件開發(fā)、網(wǎng)站改版等服務(wù),在成都10余年的網(wǎng)站建設(shè)設(shè)計(jì)經(jīng)驗(yàn),為成都上1000家中小型企業(yè)策劃設(shè)計(jì)了網(wǎng)站。
如:
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,獲取多個(gè)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"
注意:如果偏移>字符長(zhǎng)度,該字符自動(dòng)補(bǔ)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,獲取字符串中某個(gè)值的范圍
注意:對(duì)于字符串的下標(biāo),左數(shù)從0開始,右數(shù)從-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"