contentintech
Databases

Redis

Strings, hashes, expiration and transactions in redis-cli.

Updated Official documentation ↗

Strings and expiration

SET session:demo value EX 300Store a value with a five-minute TTL
GET session:demoRead a string value
INCR visitsAtomically increment an integer
TTL session:demoRead remaining TTL; -1 means no expiry, -2 means absent

Collections

HSET user:1 name Ada role engineerStore hash fields
HGETALL user:1Read all hash fields
LPUSH tasks job-1Push onto the left of a list
SADD tags backend redisAdd unique set members

Transactions and inspection

MULTIStart queuing transaction commands
EXECExecute the queued transaction
SCAN 0 MATCH user:* COUNT 100Iterate keys; continue until the returned cursor is zero
PINGCheck connectivity; avoid KEYS on large production databases

Section navigation