SET可以操作任意的类型,SET之后就变成字符串类型
APPEND:追加
192.168.2.120:6379> SET hehe hello
OK
192.168.2.120:6379> GET hehe
"hello"
192.168.2.120:6379> SET hehe hello,world
OK
192.168.2.120:6379> GET hehe
"hello,world"
192.168.2.120:6379> SET hehe hello
OK
192.168.2.120:6379> GET hehe
"hello"
192.168.2.120:6379> APPEND hehe word
(integer) 9
192.168.2.120:6379> GET hehe
"helloword"
INCR:自增
192.168.2.120:6379> INCR num
(integer) 1
192.168.2.120:6379> INCR num
(integer) 2
192.168.2.120:6379> INCR num
(integer) 3
192.168.2.120:6379> INCR num
(integer) 4
192.168.2.120:6379> INCR num
(integer) 5
192.168.2.120:6379> get num
"5"
INCRBY:以一定的量来自增
192.168.2.120:6379> get num
"5"
192.168.2.120:6379> INCRBY num 10
(integer) 15
192.168.2.120:6379> INCRBY num 10
(integer) 25
192.168.2.120:6379> GET num
"25"
DECR:每次执行减1
192.168.2.120:6379> DECR num
(integer) 24
192.168.2.120:6379> DECR num
(integer) 23
192.168.2.120:6379> DECR num
(integer) 22
192.168.2.120:6379> DECR num
(integer) 21
DECR:每次执行减设置的数值
192.168.2.120:6379> DECRBY num 5
(integer) 16
192.168.2.120:6379> DECRBY num 5
(integer) 11
192.168.2.120:6379> DECRBY num 5
(integer) 6
INCRBYFLOAT:每次执行带小数点的自增
192.168.2.120:6379> INCRBYFLOAT key 0.1
"0.1"
192.168.2.120:6379> INCRBYFLOAT key 0.1
"0.2"
192.168.2.120:6379> INCRBYFLOAT key 0.1
"0.3"
192.168.2.120:6379> INCRBYFLOAT key 0.1
"0.4"
MSET:一次可以设置多个值:
192.168.2.120:6379> MSET key1 v1 key2 v2
OK
192.168.2.120:6379> GET key1
"v1"
192.168.2.120:6379> GET key2
"v2"
MGET:一次可以GET多个值
192.168.2.120:6379> MGET key1 key2
1) "v1"
2) "v2"
STRLEN:获取字符串的长度
192.168.2.120:6379> STRLEN key1
(integer) 2
192.168.2.120:6379> STRLEN key2
(integer) 2
192.168.2.120:6379> SET KEY "阮胜昌"
OK
192.168.2.120:6379> GET KEY
"\xe9\x98\xae\xe8\x83\x9c\xe6\x98\x8c"
192.168.2.120:6379> STRLEN KEY
(integer) 9