1. Namespaced key
Colons split a key into a namespace path like user:1:name, grouping related data.
SET user:1:name "Ada"Typorithm · medium
Step 1 of 8 · intro card
Strings & Keys
Colon-delimited namespaces like user:1:name organize the flat keyspace; MSET sets many keys at once, while KEYS does a blocking O(N) pattern match best avoided in production and SCAN is its cursor-based non-blocking alternative, and EXISTS checks presence.
Redis has one flat keyspace, so teams impose structure with colon-delimited names like user:1:name and user:1:city. MSET sets several of these pairs in a single atomic command.
To find keys by pattern, KEYS user:1:* matches a glob — but it is O(N) and blocks the server while it walks every key, which can stall a busy instance, so it is reserved for debugging.
SCAN 0 MATCH user:* COUNT 100 is the production-safe alternative: it returns keys in small batches using a cursor, never blocking. EXISTS user:1:name simply reports whether a key is present (1) or not (0).
Colons namespace keys: user:1:name.
KEYS is O(N) and blocking — avoid in prod.
SCAN is the cursor-based non-blocking alternative.
SET user:1:name "Ada"
MSET user:1:age 36 user:1:city "London"
KEYS user:1:*
SCAN 0 MATCH user:* COUNT 100
EXISTS user:1:nameConnect each part of the code to the concept before you type.
Colons split a key into a namespace path like user:1:name, grouping related data.
SET user:1:name "Ada"MSET assigns several key/value pairs in a single atomic command.
MSET user:1:age 36 user:1:city "London"KEYS scans the entire keyspace for a glob pattern — O(N) and blocking, so avoid it in production.
KEYS user:1:*SCAN walks the keyspace incrementally with a cursor, never blocking the server.
SCAN 0 MATCH user:* COUNT 100EXISTS returns 1 if the key is present and 0 otherwise.
EXISTS user:1:nameRead the concept map and follow the code breakdown.
Type the implementation, repair mistakes and work through every recall exercise.
Use the final check without hints; revisit weak concepts in short practice sessions.