# 匿名访问 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支持发布订阅,具体命令以下:html
pubsub subcommanmd [args,……] //查询订阅与发布系统状态 publish channel message //将消息发送到指定频道 subscribe channel1 [channel2…… ] //订阅一个或者多个频道 unsubscribe channel1 [channel2…… ] //取消订阅 psubcribe pattern1 [pattern2 ……] //订阅一个或者多个符合给定模式的频道 punsubscribe pattern1 [pattern2 ……] //退订全部给定模式的频道
redis是彻底开源免费的,遵照BSD协议,是一个高性能的key-value数据库。redis
redis与其余key-value缓存产品对比有以下三个特色数据库