Key-value stores
The key-value model on Redis: basic commands, five value types, key naming, expiry and eviction, and what the model forbids: finding data by its content.
- 24 cards
- 5 topics
- Free
The outline, topic by topic
Each topic is weighted the way the exam weighs it.
- Concepts
- Questions
- Sort and link
- Scenarios
- Understand
A few cards from the deck
Key-value store: what is it?
Show the answer
A database that files each piece of data under a unique name and can only fetch it by that name; the stored content stays opaque to it.
This very simple model makes reads and writes extremely fast, but you cannot ask for "every value that contains this word".
What does the server answer to the last command?
```text
SET compteur 10
INCR compteur
INCR compteur
GET compteur`"12""10"(integer) 12(nil)
Show the answer
"12"INCRadds 1 on each call: 10, then 11, then 12.GETalways returns the value's text, whichredis-clishows in quotes; onlyINCRanswers with an integer.To store a token that must vanish by itself after 30 seconds, you give it a … with the … command.
Show the answer
To store a token that must vanish by itself after 30 seconds, you give it a time to live with the EXPIRE command.
SET jeton abc EX 30does both in a single atomic command: writing the value and setting the time to live.Time to live (TTL): what is it?
Show the answer
A delay, in seconds, after which the server deletes by itself an entry it was attached to.
EXPIRE session 60sets it,TTL sessiongives the time left:-1if the key never expires,-2if it does not exist (any more).A Redis cache refuses writes with "OOM command not allowed when used memory > 'maxmemory'". The keys have no time to live. Which fix is right?
- Set
maxmemoryto 0 so that memory is no longer limited - Give the keys a time to live and pick the
allkeys-lrueviction - Add an index on the values so that they are found faster
- Restart the server every night so that its memory is emptied
Show the answer
Give the keys a time to live and pick the
allkeys-lruevictionWith the default
noevictionpolicy, a full server refuses to write rather than delete anything. Times to live let stale entries leave on their own, andallkeys-lruevicts the rest when needed. With no limit, a cache that never drops anything grows until it exhausts the machine's memory.- Set