安装
https://github.com/tporadowski/redis/releases
https://github.com/zkteco-home/redis-windows 支持7.0 windows
https://github.com/dragonflydb/dragonfly 替代redis
https://github.com/nalgeon/redka
./redka -h 0.0.0.0 -p 6379 data.db
Memcached用c++
远程连接
修改redis服务器的配置文件redis.windows.conf
注释绑定的主机地址# bind 127.0.0.1改0.0.0.0
修改redis的保护模式为no,不启用protected-mode"no"
requirepass 123456 设置密码用户名为空
auth 123456 登录
daemonize yes 后台启动配置常用命令
linux 安装sudo apt-get install redis-server启动redis-server
redis.conf配置,下面是dump.rdb路径,用save生成,查看config get dirroot启动才能使用savedir /var/lib/redis
cha查看模块 module list
安装最新redis
sudo apt-get install software-properties-common -y
sudo add-apt-repository ppa:chris-lea/redis-server -y
sudo apt-get update && sudo apt-get install redis-server -y
tar -xvf redis.tar.gz
cd redis
make
make install
redis-server /etc/redis/redis.conf 运行
loadmodule /home/redis/rejson.so //加载模块
redis-server -v
- 启动redis命令
redis-cli - 查看信息
info - 选择数据库
select 0 - 删除当前数据库中的所有Key
flushdb - 删除所有数据库中的key
flushall - 连接是否正常,返回pong正常
ping - 密码 auth 12
- 输出字符
echo hello - 获取所有键
keys * - 判断是否存在某个键 存在1,不存在0
exists id - 删除键,成功返回1,失败或不存在0,删除两个返回2,支持所有类型
del iddel id1 id2 - 返回字段类型string 字符串 hash散列 list列表 set集合 zset有序集合
type id - 过期时间 秒,1表示成功,0表示不存在id,设置失败
expire id 10 - 查看剩余过期秒数,永久存在-1 ,id不存在-2
ttl id - 取消过期,set,getset也会清除
persist id - 排序,支持列表,集合,有序集合,支持by 和get 参数
sort idsort id alpha用于字典非数字元素sort id desc从大到小sort id desc limit 2 5从第二个开始取5个sort id store ids排序结果保存到ids,加上过期时间,实现缓存功能 - 队列,使用列表实现
rpop id队列取出brpop id 0没有元素会等待取出,超时时间0blpop id 0从左边取出brpop id id1 0支持多个队列取值,比如实现订阅邮件,刚刚订阅就触发 - 查看编码方式
object encoding id
作者:Yoby 创建时间:2020-07-22 21:03
最后编辑:Yoby 更新时间:2025-05-22 01:28
最后编辑:Yoby 更新时间:2025-05-22 01:28