连接
redis-cli -h ip -p port -a password
[user@test ~]$ redis-cli -h 192.*.*.* -p 6379 -a '******'
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
192.*.*.*:6379>
默认选择db0
若需要切换db,use ‘select dbNum’
192.*.*.*:6379> SELECT 1
OK
查看所有的key
192.*.*.*:6379[1]> keys *
1) "key1"
2) "key2"
3) "key3"
查看key的存储类型
192.*.*.*:6379[1]> type 'stock_data'
list
查看list型的大小
192.*.*.*:6379[1]> llen 'key1'
(integer) 47410
判断某个Key是否存在
192.*.*.*:6379[1]> exists 'key1'
(integer) 1
删除某个key值
192.*.*.*:6379[1]> del 'key1'
(integer) 1
为key取新的名字
192.*.*.*:6379[1]> rename 'key1' 'key2'
OK