Key design
On This Lesson 4 topics
This lesson is planned. The outline below lists the topics it will cover. The full lesson has not been published yet.
In this lesson
name keys so they can be found, expired, and invalidated safely.
Planned topics
- Use namespaces with colons:
shop:product:42:v1. - Include a version in the key to change formats without clashes.
- Keep keys short but readable; large key sets cost memory.
- Never use
KEYS *in production; it scans everything and blocks. UseSCANwith a match pattern. - Group related keys (or use a version/tag key) so invalidation does not need scanning.
Draft outline details
Demonstration
shop:product:{id}, shop:category:{id}:products, shop:catalog:version = 7 (key includes the version, bump to invalidate a family).
Check your understanding
Why avoid KEYS *?
Show answer
It is O(n) and blocks the single thread.
Practice
Apply this lesson with the module's lab, exercises and quiz.
Marking a lesson complete is optional and you can undo it any time. Your progress stays in this browser.