Show Menu
Cheatography

redis Cheat Sheet (DRAFT) by

This is a draft cheat sheet. It is a work in progress and is not finished yet.

Keys

DEL key ...
Delete item(s)
redis.Int
EXISTS key
Check for key
redis.Int
EXPIRE key seconds
Set timeout on item
redis.Int
EXPIREAT key timestamp
Set timeout by timestamp
redis.Int
PEXPIRE key millis­econds
Set timeout (ms)
redis.Int
PEXPIREAT key millis­eco­nds­-ti­mestamp
Set timeout (ms timestamp)
redis.Int
PTTL key
Get item time to live (ms)
redis.Int
TTL key
Get item time to live
redis.Int

Strings

GET key
Get value of key
redis.S­tring
INCR key
Increment integer
redis.Int
INCRBY key increment
Increment integer
redis.Int
SET key value [EX second] [NX|XX]
Set key
redis.S­tring
SETEX key seconds value
Set with expiry (seconds)
redis.S­tring
SETNX key value
Set if doesn't exist
redis.Int

Hashes

HDEL key field ...
Delete item
redis.Int
HEXISTS key field
Check for item
redis.Int
HGET key field
Get item
redis.S­tring
HGETALL key
Return all items
redis.S­tr­ings/ redis.S­tr­ingMap
HINCRBY key field increment
Add to integer value
redis.Int
HINCRB­YFLOAT key field increment
Add to float value
redis.F­loat64
HKEYS key
Return all keys
redis.S­trings
HLEN key
Get number of items
redis.Int
HMGET key field ...
Get multiple items
redis.S­trings
HMSET key field value ...
Set multiple items
redis.S­tr­ing­s/r­edi­s.S­tri­ngMap
HSET key value
Set item
redis.Int
HSETNX key value
Set item if doesn't exist
redis.Int
HSCAN key cursor [MATCH pattern] [COUNT count]
Iterate items
redis.M­ul­tiBulk

Lists

LINDEX key index
Access by index
redis.S­tring
LINSERT key BEFORE­|AFTER pivot value
Insert next to
redis.Int
LLEN key
Get length
redis.Int
LPOP key
Pop from start
redis.S­tring
LPUSH key value ...
Push onto start
redis.Int
LPUSHX key value
Push if list exists
redis.Int
LRANGE key start stop
Access range
redis.S­trings
LREM key count value
Remove
redis.Int
LSET key index value
Set item by index
redis.S­tring
LTRIM key start stop
Trim to specified range
redis.S­tring
RPOP key
Pop from end
redis.S­tring
RPUSH key value ...
Push onto end
redis.Int
RPUSHX key value
Push onto end if list exists
redis.Int

Sets

SADD key member ...
Add item
redis.Int
SCARD key
Get size
redis.Int
SISMEMBER key member
Check for item
redis.Int
SPOP key
Pop random item
redis.S­tring
SRANDM­EMBER key count
Get random item
redis.S­trings
SREM key member ...
Remove matching
redis.Int
SSCAN key cursor [MATCH pattern] [COUNT count]
Iterate items
redis.M­ul­tiBulk

Sorted Sets

ZADD key score member...
Add item
redis.Int
ZCARD key
Get number of items
redis.Int
ZCOUNT key min max
Number of items within score range
redis.Int
ZINCRBY key increment member
Add to score
redis.S­tring
ZRANGE key start stop [WITHS­CORES]
Get items within rank range
redis.S­tr­ings/ redis.S­tr­ingMap
ZRANGE­BYSCORE key min max [WITHS­CORES] [LIMIT offset count]
Get items within score range
redis.S­tr­ings/ redis.S­tr­ingMap
ZRANK key member
Get item rank
redis.Int
ZREM key member ...
Remove item(s)
redis.Int
ZREMRA­NGE­BYRANK key start stop
Remove items within rank range
redis.Int
ZREMRA­NGE­BYSCORE key min max
Remove items within score range
redis.Int
ZREVRANK key member
ZRANGE in reverse order
redis.Int
ZSCORE key member
Get item score
redis.S­tring
ZSCAN key cursor [MATCH pattern] [COUNT count]
Iterate items
redis.M­ul­tiBulk