redis通用命令
select 3#切换数据库3
info#查看redis信息
info replication#查看主从复制状况
keys *#查看所有的key
type key1#查看key数据库类型
exists key1#key是否存在
del key1#删除一个key
rename key key1#重命名
flushdb/flushall#清空数据库
string类型
C:\Users\wsh> localhost:6379> set name jack#设置key_value OK localhost:6379> mset name jack age 23 addr china OK localhost:6379> append key val#追加 (integer) 3 localhost:6379> get name#获取key的值 "jack" localhost:6379> mget name age hobby
-
"jack"
-
"23"
-
(nil) localhost:6379> r.get("name")#python实现返回字符串
-
Invalid argument(s) localhost:6379> r.mget("name","age","hobby")#返回值列表 Invalid argument(s) localhost:6379> set name jack ex 10#设置key时间10s过期 OK localhost:6379> set name jack nx#不存在时,设置key (nil) localhost:6379> srrlen name (error) ERR unknown command
srrlen
, with args beginning with:name
, localhost:6379> strlen name#获取字符串长度 (integer) 0 localhost:6379> r.strlen("name")#python实现 Invalid argument(s) localhost:6379> r.set("name","jack")#获取字符串分片 Invalid argument(s) localhost:6379> r.getrange("name",0,1) Invalid argument(s) localhost:6379> set name beikehan#设置字符串的片段值 OK localhost:6379> setrange name 1 (error) ERR wrong number of arguments for 'setrange' command localhost:6379> setrange name 1 oo (integer) 8 localhost:6379> r.setrange("name",1,"oo") Invalid argument(s) localhost:6379> set age 23 OK localhost:6379> incr age#数据加1 (integer) 24 localhost:6379> desc age (error) ERR unknown commanddesc
, wit