0
0
Redisquery~10 mins

Key naming conventions (colons for namespacing) in Redis - Step-by-Step Execution

Choose your learning style9 modes available
Concept Flow - Key naming conventions (colons for namespacing)
Start with base key
Add colon ':' separator
Add namespace segment
Repeat colon + segment as needed
Final key formed
Use key in Redis commands
This flow shows how Redis keys are built by joining parts with colons to create namespaces for better organization.
Execution Sample
Redis
SET user:1000:name "Alice"
GET user:1000:name
SET user:1000:email "alice@example.com"
GET user:1000:email
This code sets and gets Redis keys using colons to separate namespaces like 'user' and '1000'.
Execution Table
StepCommandKey UsedActionResult
1SET user:1000:name "Alice"user:1000:nameStore value 'Alice'OK
2GET user:1000:nameuser:1000:nameRetrieve value"Alice"
3SET user:1000:email "alice@example.com"user:1000:emailStore value 'alice@example.com'OK
4GET user:1000:emailuser:1000:emailRetrieve value"alice@example.com"
5END-No more commandsExecution complete
💡 All commands executed; keys used with colons to separate namespaces.
Variable Tracker
KeyInitialAfter Step 1After Step 3Final
user:1000:namenull"Alice""Alice""Alice"
user:1000:emailnullnull"alice@example.com""alice@example.com"
Key Moments - 2 Insights
Why do we use colons ':' in Redis keys?
Colons act as separators to create namespaces, making keys easier to organize and find, as shown in steps 1 and 3 where keys like 'user:1000:name' are used.
Can Redis keys have spaces instead of colons?
While Redis keys can technically have spaces, using colons is a common convention for clarity and to avoid confusion, as demonstrated in the execution_table keys.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table, what value is stored at step 1 for key 'user:1000:name'?
A"Alice"
B"alice@example.com"
Cnull
D"Bob"
💡 Hint
Check the 'Result' column in row 1 of the execution_table.
At which step is the key 'user:1000:email' first set?
AStep 2
BStep 1
CStep 3
DStep 4
💡 Hint
Look at the 'Command' and 'Key Used' columns in the execution_table.
If we replaced colons ':' with dashes '-' in keys, what would change in the execution_table?
AValues stored would change
BKeys would show dashes instead of colons in the 'Key Used' column
CCommands would fail to execute
DNo change at all
💡 Hint
Consider how keys are displayed in the 'Key Used' column and Redis key naming rules.
Concept Snapshot
Redis keys use colons ':' to separate parts, creating namespaces.
Example: user:1000:name stores a user's name.
This helps organize keys logically.
Commands use full keys with colons.
Colons are just characters, no special Redis meaning.
Use consistent naming for clarity.
Full Transcript
In Redis, keys are named using colons ':' to separate different parts, like namespaces. This helps keep keys organized, for example 'user:1000:name' stores the name of user 1000. Commands like SET and GET use these full keys. The colon is just a character used to separate parts, making keys easier to read and manage. This visual shows setting and getting keys with colons, tracking values stored and retrieved step-by-step.