Redis Cheat Sheet
by James Hopkin (tasjaevan) via cheatography.com/18964/cs/2046/
Strings
Lists (cont)
Database
APPEND
Append
LPUSH
Push onto start
DEL
Delete item
BITCOUNT
Count set bits
LPUSHX
Push if list exists
DUMP
Serialise item
BITOP
Bitwise operations
LRANGE
Access range
EXISTS
Check for key
BITPOS
Find first set bit
LREM
Remove
EXPIRE
Set timeout on item
DECR
Decrement integer
LSET
Set item by index
EXPIREAT
Set timeout by timestamp
DECRBY
Subtract from integer
LTRIM
Remove start and/or end
KEYS
Get all keys matching pattern
items
MIGRATE
Transfer an item between
GET
Get by key
GETBIT
Get bit by index
RPOP
GETRANGE
Get substring
RPOPLPUSH
Rotate
GETSET
Set, returning old value
RPUSH
Push onto end
INCR
Increment integer
RPUSHX
Push onto end if list exists
INCRBY
Add to integer
INCRBYFLOAT
Add to float
MGET
Get multiple
MSET
Set multiple
MSETNX
Set multiple if don't exist
PSETEX
Set with expiry (ms)
SET
Set
SETBIT
Set bit by index
SETEX
Set only if already exists
SETNX
Set if doesn't exist
SETRANGE
Set substring
STRLEN
Get length
Strings can be used as numbers, arrays, bit
sets and binary data
Lists
BLPOP
Blocking left pop
BRPOP
Blocking right pop
BRPOPLPUSH
Blocking rotate
LINDEX
Access by index
LINSERT
Insert next to
LLEN
Get length
LPOP
Pop from start
Pop from end
Redis instances
MOVE
Transfer an item between
databases
OBJECT
Inspect item
PERSIST
Remove timeout
Client/Server
PEXPIRE
Set timeout (ms)
AUTH
Request authentication
PEXPIREAT
Set timeout (ms timestamp)
ECHO
Return message
PTTL
Get item time to live (ms)
PING
Test connection
RANDOMKEY
Get random key
QUIT
Close connection
RENAME
Change item's key
SELECT
Set current database by index
RENAMENX
Change item's key if new key
doesn't exist
Sets
RESTORE
Deserialise
SADD
Add item
SCAN
Iterate keys
SCARD
Get size
SORT
Get or store sorted copy of
SDIFF
Get difference
SDIFFSTORE
Store difference
SINTER
Intersection
SINTERSTORE
Store intersection
SISMEMBER
Check for item
SMEMBERS
Get all
SMOVE
Move item to another set
SPOP
Pop random item
SRANDMEMBER
Get random item
SREM
Remove matching
SSCAN
Iterate items
SUNION
Union
SUNIONSTORE
Store union
list, set or sorted set
TTL
Get item time to live
TYPE
Get type of item
By James Hopkin (tasjaevan)
Published 8th May, 2014.
Sponsored by Readability-Score.com
cheatography.com/tasjaevan/
Last updated 28th June, 2014.
Measure your website readability!
Page 1 of 2.
https://readability-score.com
Redis Cheat Sheet
by James Hopkin (tasjaevan) via cheatography.com/18964/cs/2046/
Scripts
Sorted sets (cont)
EVAL
Run
EVALSHA
Run cached
SCRIPT EXISTS
Check by hash
SCRIPT FLUSH
Clear cache
SCRIPT KILL
Kill running script
SCRIPT LOAD
Add to cache
Lua scripts access keys through the array
ZLEXRANGE
Get items within
lexicographical
range
ZRANGEBYSCORE
Get items within
score range
ZRANK
Get item rank
ZREM
Remove item(s)
ZREMRANGEBYLEX
Remove items
KEYS and additional arguments through the
within
array ARGV.
lexicographical
range
Hashes
ZREMRANGEBYRANK
Remove items
within rank range
HDEL
Delete item
HEXISTS
Check for item
HGET
Get item
HGETALL
Return all items
HINCRBY
Add to integer value
HINCRBYFLOAT
Add to float value
HKEYS
Return all keys
HLEN
Get number of items
HMGET
Get multiple items
ZSCAN
Iterate items
HMSET
Set multiple items
ZSCORE
Get item score
HSCAN
Iterate items
ZUNIONSTORE
Store union
HSET
Set item
Lexicographical commands require all items to
HSETNX
Set item if doesn't exist
have the same score
HVALS
Return all values
Sorted sets
ZREMRANGEBYSCORE
Remove items
within score range
ZREVRANGE
ZRANGE in
reverse order
ZREVRANGEBYSCORE
ZRANGEBYSCOR
E in reverse order
ZREVRANK
ZRANK in reverse
order
HyperLogLogs
PFADD
Add items
ZADD
Add item
PFCOUNT
Get approximate size
ZCARD
Get number of items
PFMERGE
Merge HyperLogLogs
ZCOUNT
Number of items within score
range
ZINCRBY
Add to score
ZINTERSTORE
Store intersection
ZLEXCOUNT
Lexicographical range count
ZRANGE
Get items within rank range
By James Hopkin (tasjaevan)
Published 8th May, 2014.
Sponsored by Readability-Score.com
cheatography.com/tasjaevan/
Last updated 28th June, 2014.
Measure your website readability!
Page 2 of 2.
https://readability-score.com