1.賦值
set key value
如果key已存在,則value被新值覆蓋
2.取值localhost:6379> set name yanlei
ok
get key value
3.遞增數值localhost:6379> get name
"yanlei"
incr key (key的value必須為數字)
4.增加指定整數localhost:6379> get name
"yanlei"
localhost:6379> set index 1
oklocalhost:6379> get index
"1"localhost:6379> incr index
(integer) 2
localhost:6379> incr index
(integer) 3
localhost:6379> get index
"3"localhost:6379> set name yanlei
oklocalhost:6379> incr name
(error) err value is not an integer or out of range//非數字報錯
incrby key num
5.遞減數值localhost:6379> set index 1
oklocalhost:6379> incrby index 5
(integer) 6
decr key
6.減少指定整數localhost:6379> set index 10
oklocalhost:6379> decr index
(integer) 9
decrby key num
7.增加指定的浮點數localhost:6379> set index 10
oklocalhost:6379> decrby index 6
(integer) 4
incrbyfloat key floatvalue
8.向尾部增加字串127.0.0.1:6379> set price 7.7
ok127.0.0.1:6379> incrbyfloat price 1.1
"8.8"
9.獲取字串長度localhost:6379> set city shengyang
ok(integer) 18
localhost:6379> get city
"shengyang of china"
strlen key
10.設定(獲取)多個鍵 值localhost:6379> set money 123456
oklocalhost:6379> strlen money
(integer) 6
mset key1 value1 key2 value2 ....
mget key1 key2 ...
localhost:6379> mset brand focus color block price 120000
oklocalhost:6379> mget brand color price
1) "focus"
2) "block"
3) "120000"
Redis 常用命令學習二 字串型別命令
1.賦值與取值命令 127.0.0.1 6379 set foo helloredis ok127.0.0.1 6379 get foo helloredis 127.0.0.1 6379 get bar nil 2.數字鍵值遞增 127.0.0.1 6379 set int 3 ok127.0.0...
Redis筆記part2(字串)
設定乙個key set key hello 獲取這個key值 get key 追加字元 獲取字串長度 strlen key 一次設定多個key mset key1 v1 key2 v2 一次獲取多個key mget key1 key2 一次刪除多個key mdel key1 key2 獲取所有的ke...
025 字串型別
目錄 二 如何用 表示名字 愛好 字串相當於一根羊肉串。而字串就是一串被串起來的字元,在單引號 雙引號或三引號內包裹的一串字元。需要注意的是 三引號內的字元可以換行,而單雙引號內的字元不行。name1 nick name2 egon print id name1 print type name1 p...