Reference Reference reference

GET / SET 参考

GET / SET 是 Redis 开发和运维中的高频命令组合。使用前要确认 key 命名、过期策略和数据结构是否符合业务模型。

语法

text
SET key value [EX seconds]
GET key

最小示例

redis
SET user:1:name Tom EX 3600
GET user:1:name

常见错误

  • 没有设置过期时间,缓存 key 长期堆积。
  • 把大对象或大集合塞进单个 key,导致阻塞和内存压力。
  • 缓存值缺少序列化约定会导致不同语言解析失败。

相关内容