⚡ 100% In-Browser & Private: Your data never leaves your computer. Powered by Cloudflare Edge CDN.
ProWebTools PRO
Developer & SEO Utilities
30+ Commands

Redis CLI & In-Memory Data Store Cheat Sheet

The definitive Redis CLI reference: key TTL management, atomic counters (INCR), hash maps (HSET, HGETALL), list queues (LPUSH, BRPOP), sorted sets (ZADD), and memory diagnostics with 1-click copy.

Keys & Lifecycle (6 commands)

Keys & Lifecycle
redis-cli -h 127.0.0.1 -p 6379 -a "mypassword"

Connects to a remote or local Redis instance using the command-line client.

PRO TIP Pass --tls for encrypted enterprise clusters.
Keys & Lifecycle
PING

Tests connectivity to the Redis server. Returns PONG if healthy.

PRO TIP Useful for health-check probes in Docker and Kubernetes liveness checks.
Keys & Lifecycle
EXPIRE <key> 3600

Sets a Time-To-Live (TTL) timeout in seconds on the target key.

PRO TIP Use PEXPIRE for millisecond resolution timeouts.
Keys & Lifecycle
TTL <key>

Returns remaining lifetime in seconds (-1 = persistent, -2 = key expired/missing).

PRO TIP Use PTTL for millisecond precision remaining time.
Keys & Lifecycle
PERSIST <key>

Removes the existing expiration timeout, making the key permanently stored in memory.

PRO TIP Returns 1 if timeout was removed, 0 if key does not exist or has no timeout.
Keys & Lifecycle
DEL <key1> <key2>

Deletes one or more keys synchronously from memory.

PRO TIP Use UNLINK instead of DEL for large keys (sets, hashes) to delete in background.

Strings & Counters (4 commands)

Strings & Counters
SET <key> "value" EX 300 NX

Sets key with 300s TTL only if it does not already exist (distributed lock pattern).

PRO TIP NX ensures atomic check-and-set behavior essential for mutual exclusion locks.
Strings & Counters
GET <key>

Retrieves the string value stored at key.

PRO TIP Returns nil if key does not exist.
Strings & Counters
INCR <counter_key>

Atomically increments the integer value of a key by one.

PRO TIP Use INCRBY to increment by custom values (e.g. INCRBY api_credits 50).
Strings & Counters
MGET <key1> <key2> <key3>

Batches multiple string lookups in a single round-trip network call.

PRO TIP Substantially reduces network latency overhead compared to separate GET calls.

Hashes (Objects) (3 commands)

Hashes (Objects)
HSET user:1001 name "Elena" role "admin" visits 42

Sets multiple field-value pairs in a hash object representing an entity.

PRO TIP Hashes use memory-efficient ziplist encodings for small field counts.
Hashes (Objects)
HGETALL user:1001

Returns all fields and values stored in the specified hash object.

PRO TIP Use HGET user:1001 when only a specific attribute is required.
Hashes (Objects)
HINCRBY user:1001 visits 1

Atomically increments a specific numeric field inside a hash object.

PRO TIP Ideal for session hit counts, rate limit buckets, and user activity meters.

Lists & Queues (3 commands)

Lists & Queues
LPUSH task_queue "job_payload_json"

Pushes an item onto the head (left side) of a list queue.

PRO TIP Combine with RPOP for standard FIFO queue processing.
Lists & Queues
BRPOP task_queue 10

Blocking pop: removes and returns last item, or blocks up to 10s waiting for jobs.

PRO TIP Eliminates busy-polling loops in background worker microservices.
Lists & Queues
LRANGE user_feed:101 0 19

Retrieves a slice of items from index 0 to 19 (pagination).

PRO TIP Pass 0 -1 to retrieve all elements stored in the list.

Sets & Sorted Sets (4 commands)

Sets & Sorted Sets
SADD tags:article:42 "tech" "cloud" "devops"

Adds unique member strings to an unordered mathematical set.

PRO TIP Duplicates are discarded automatically.
Sets & Sorted Sets
SISMEMBER tags:article:42 "cloud"

Checks if an element belongs to the set with O(1) time complexity.

PRO TIP Returns 1 if member exists, 0 otherwise.
Sets & Sorted Sets
ZADD leaderboard 1500 "user_alice" 2200 "user_bob"

Adds members with numeric scores into a sorted set for ranking algorithms.

PRO TIP Members are ordered automatically by score.
Sets & Sorted Sets
ZREVRANGE leaderboard 0 9 WITHSCORES

Retrieves the top 10 highest-ranked members along with their scores.

PRO TIP Ideal for high-concurrency gaming and real-time activity leaderboards.

Pub/Sub & Server Health (3 commands)

Pub/Sub & Server Health
PUBLISH notifications "New invoice created"

Broadcasts a message to all subscribers listening on the notifications channel.

PRO TIP Subscribers listen via SUBSCRIBE .
Pub/Sub & Server Health
INFO memory

Inspects allocated memory, peak memory, RSS, and fragmentation ratio.

PRO TIP Keep mem_fragmentation_ratio between 1.0 and 1.5 for healthy memory usage.
Pub/Sub & Server Health
FLUSHDB ASYNC

Deletes all keys in the currently selected database non-blockingly.

PRO TIP ASYNC prevents blocking the Redis single thread during large dataset purges.