redis-常用命令
1、string
设定:
127.0.0.1:6379> set myKey abc
OK
获取:
127.0.0.1:6379> get myKey
"abc"
删除:
127.0.0.1:6379> del myKey
(integer) 1
2、hash
设定:
127.0.0.1:6379> hset human name flt
(integer) 1
127.0.0.1:6379> hset human sex man
(integer) 1
获取:
127.0.0.1:6379> hget human name
"flt"
127.0.0.1:6379> hgetall human
1) "name"
2) "flt"
3) "sex"
4) "man"
删除:
127.0.0.1:6379> hdel human name
(integer) 1
3、list
设定:
127.0.0.1:6379> lpush list1 1,2,3,4
(integer) 1
127.0.0.1:6379> lpush list2 A,B,C,D
(integer) 1
获取:
127.0.0.1:6379> lrange list1 0 -1
1) "1,2,3,4"
127.0.0.1:6379> lrange list2 0 -1
1) "A,B,C,D"
删除:
127.0.0.1:6379> lpop list1
"1,2,3,4"
4、set
设定:
127.0.0.1:6379> sadd set1 1
(integer) 1
127.0.0.1:6379> sadd set1 2
(integer) 1
获取:
127.0.0.1:6379> smembers set1
1) "1"
2) "2"
删除:
127.0.0.1:6379> srem set1 1
(integer) 1
5、sorted
设定:
127.0.0.1:6379> zadd sort 1 xiaomi
(integer) 1
127.0.0.1:6379> zadd sort 2 huawei
(integer) 1
获取:
127.0.0.1:6379> zrange sort 0 -1
1) "xiaomi"
2) "huawei"
删除:
127.0.0.1:6379> zrem sort xiaomi
(integer) 1