1.库相关
select 索引 =》 选择库
dbsize =》 查询当前库中Key的数量
flushdb =》 清空当前库
flushall =》 清空所有库(建议不要用,除非你跑路)
2.Key相关
keys * =》 取出当前库所有Key
exists {Key} =》 判断Key是否存在,存在返回1,不存在返回0
move {Key} {DbIndex} =》 从当前库剪切指定Key到指定库中
expire {Key} {秒} =》 为指定的Key设置过期时间
ttl {Key} =》 查看指定Key还有多少秒过期,-1表示永不过期,-2表示已过期
type {Key} =》 查看Key是什么类型
3.String相关
set {Key} {Value} =》 新建一个String类型的缓存数据
get {Key} =》 根据Key获取Value
del {Key} =》 根据Key删除缓存
append {Key} {String} =》 根据Key在Value的末尾增加字符串
strlen {Key} =》 根据Key返回Value的长度
incr {Key} =》 对指定Key的Value数值加1(要求Value可以转换为数值,否则返回错误)
decr {Key} =》 对指定Key的Value数值减1(要求Value可以转换为数值,否则返回错误)
incrby {Key} {Num} =》 对指定Key的Value数值加Num(要求Value可以转换为数值,否则返回错误)
decrby {Key} {Num} =》 对指定Key的Value数值减Num(要求Value可以转换为数值,否则返回错误)
getrange {Key} {StartNum} {EndNum} =》 根据Key获取Value指定区域范围内的值(只是返回并没有对Value进行截取)
setrange {Key} {StartNum} {String} =》 根据Key对Value指定区间范围内的值进行覆写
setex {Key} {秒} {Value} =》 新建一个String类型的缓存数据并设置过期时间
setnx {Key} {Value} =》 新建一个String类型的缓存数据,存在则不进行任何操作,不存在则创建。
mset {Key1} {Value1} {Key2} {Value2}... =》 用于同时创建多个String类型的缓存数据
mget {Key1} {Key2}.... =》 用于同时获取多个Key的Value
msetnx {Key1} {Value1} {Key2} {Value2}... =》 用于同时创建多个String类型的缓存数据,若其中某一个Key已经存在,则不执行任何操作。
getset {Key} {Value} => 先获取指定Key的Value值,如不存在则返回null,然后对指定Key设置Value值。(先get后set)
4.List相关