- 查看key的类型 127.0.0.1:6379[2]> type phone
- 查看key所对应的value值的长度127.0.0.1:6379> strlen age
- 127.0.0.1:6379> incr views
- 127.0.0.1:6379> decr views
- 127.0.0.1:6379> incrby views 10
- 127.0.0.1:6379> decrby views 2
- 127.0.0.1:6379> getrange key1 0 3
-
127.0.0.1:6379> setrange key1 1 xxx
- 127.0.0.1:6379> setex key3 30 hello
- 127.0.0.1:6379> ttl key3
- 127.0.0.1:6379> setnx mykey "redis"
-
127.0.0.1:6379> setnx mykey "MongoDB"
(integer) 0
127.0.0.1:6379> get mykey
"redis" -
127.0.0.1:6379> mset k1 v1 k2 v2 k3 v3
OK -
127.0.0.1:6379> mget k1 k2 k3
1) "v1"
2) "v2"
3) "v3" -
127.0.0.1:6379> msetnx k1 v1
(integer) 0 -
127.0.0.1:6379> mget k1 k2 k3 k4
1) "v1"
2) "v2"
3) "v3"
4) (nil)
127.0.0.1:6379> get k4
(nil)
127.0.0.1:6379> mset user:1:name zhangsan user:1:age 2
OK
127.0.0.1:6379> mget user:1:name user:1:age
1) "zhangsan"
2) "2"
127.0.0.1:6379> getset db redis
(nil)
127.0.0.1:6379> get db
"redis"
127.0.0.1:6379> getset db mongodb
"redis"
127.0.0.1:6379> get db
"mongodb"
127.0.0.1:6379> getset db hbase
"mongodb"