Redis 缓存
[cache]cache_type = "Redis"redis_url = "redis://localhost:6379"max_size_mb = 100- 商品目录查询
- 分类列表
- 会话数据
- 限流器状态
不用 Redis
Section titled “不用 Redis”默认是内存缓存(cache_type = "Memory")。单节点部署这就够用了
—— Redis 是可选的,不是必需的。只有当你运行多个需要共享
缓存/会话/限流状态的 API 实例,或希望缓存能熬过重启时,才需要
Redis。
Redis 安装配置
Section titled “Redis 安装配置”# 安装 Redissudo apt install redis-server
# 配置 Redissudo vim /etc/redis/redis.conf# 设置: requirepass your_password
# 更新 rCommerce 配置[cache]cache_type = "Redis"redis_url = "redis://:your_password@localhost:6379"有了 Redis,多个 rCommerce 实例可以共享缓存和会话数据:
Instance 1 → Redis ← Instance 2以下操作会自动失效缓存:
- 商品创建/更新/删除
- 分类变更
- 下单
- 配置变更