【redis】redis-config详解
狂神老师的视频地址:https://space.bilibili.com/95256449
这里用window下的配置文件配合来看
1、单位
可以看到,可以在配置文件里设置单位,并且对大小写不敏感
# Note on units: when memory size is needed, it is possible to specify # it in the usual form of 1k 5GB 4M and so forth: # # 1k => 1000 bytes # 1kb => 1024 bytes # 1m => 1000000 bytes # 1mb => 1024*1024 bytes # 1g => 1000000000 bytes # 1gb => 1024*1024*1024 bytes # # units are case insensitive so 1GB 1Gb 1gB are all the same.
2、包含
和springboot配置文件类似,配置文件可以包含其他配置文件
# Include one or more other config files here. This is useful if you # have a standard template that goes to all Redis servers but also need # to customize a few per-server settings. Include files can include # other files, so use this wisely. # # Notice option "include" won't be rewritten by command "CONFIG REWRITE" # from admin or Redis Sentinel. Since Redis always uses the last processed # line as value of a configuration directive, you'd better put includes # at the beginning of this file to avoid overwriting config change at runtime. # # If instead you are interested in using includes to override configuration # options, it is better to use include as the last line. # # include .\path\to\local.conf # include c:\path\to\other.conf
3、网络
bind 127.0.0.1 #绑定IP protected-mode yes #保护模式 port 6379 #端口设置
4、通过设置
设置密码,可在参数文件中设置,一般在命令中设置
C:\Users\86155>redis-cli 127.0.0.1:6379> config get requirepass 1) "requirepass" 2) "" 127.0.0.1:6379> config set requirepass (error) ERR Unknown subcommand or wrong number of arguments for 'set'. Try CONFIG HELP. 127.0.0.1:6379> config set requirepass 123456
# maxclients 10000 #最大并发数 # maxmemory <bytes> #最大内存 # maxmemory-policy noeviction #内存满了之后的拒绝策略 有以下六中策略 1、volatile-lru:只对设置了过期时间的key进行LRU(默认值) 2、allkeys-lru : 删除lru算法的key 3、volatile-random:随机删除即将过期key 4、allkeys-random:随机删除 5、volatile-ttl : 删除即将过期的 6、noeviction : 永不过期,返回错误
APPEND ONLY MODE
appendonly no #默认不开启 aof,默认使用rdb,一般够用 appendfilename "appendonly.aof" #持久化文件的名字 # appendfsync always #每次修改都会同步 appendfsync everysec #每秒执行一次同步,可能会丢失这1s的数据 # appendfsync no #不同步 具体的配置Redis持久化会记录
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· 写一个简单的SQL生成工具
· AI 智能体引爆开源社区「GitHub 热点速览」
· C#/.NET/.NET Core技术前沿周刊 | 第 29 期(2025年3.1-3.9)