# 匿名访问
redis-cli -h ip_address -p port
# 密码访问
redis-cli -h ip_address -p port -a password
# 以 aaa 结尾的 key
keys *aaa
# 以 aaa 开头的 key
keys aaa*
# 完全模糊匹配包含 aaa 的key
keys *aaa*
get key
DEL key
expire_key seconds //为给定key设置过期时间,以秒为单位
pexpire_key milliseconds //使设置key的过期时间,以毫秒为单位
persist key //移除key过期时间,key将永久保持
TTL key //返回过期时间以秒为单位
PTTL key //返回过期时间以毫秒为单位
TYPE key
SAVE //备份
bgsave //后台备份
config get dir //恢复数据
redis支持发布订阅,具体命令如下:
pubsub subcommanmd [args,……] //查询订阅与发布系统状态
publish channel message //将消息发送到指定频道
subscribe channel1 [channel2…… ] //订阅一个或者多个频道
unsubscribe channel1 [channel2…… ] //取消订阅
psubcribe pattern1 [pattern2 ……] //订阅一个或者多个符合给定模式的频道
punsubscribe pattern1 [pattern2 ……] //退订所有给定模式的频道
redis是完全开源免费的,遵守BSD协议,是一个高性能的key-value数据库。
redis与其他key-value缓存产品对比有如下三个特点
参考:https://www.runoob.com/redis/redis-intro.html
原文:https://www.cnblogs.com/amyzhu/p/13126289.html