Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

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

GET Get by key items MIGRATE Transfer an item between


RPOP Pop from end Redis instances
GETBIT Get bit by index
RPOPLPUSH Rotate MOVE Transfer an item between
GETRANGE Get substring
databases
GETSET Set, returning old value RPUSH Push onto end

RPUSHX Push onto end if list exists OBJECT Inspect item


INCR Increment integer
PERSIST Remove timeout
INCRBY Add to integer
Client​/Server PEXPIRE Set timeout (ms)
INCRBYFLOAT Add to float
AUTH Request authen​tic​ation PEXPIREAT Set timeout (ms timestamp)
MGET Get multiple
ECHO Return message PTTL Get item time to live (ms)
MSET Set multiple
PING Test connection RANDOMKEY Get random key
MSETNX Set multiple if don't exist
QUIT Close connection RENAME Change item's key
PSETEX Set with expiry (ms)
SELECT Set current database by index RENAMENX Change item's key if new key
SET Set
doesn't exist
SETBIT Set bit by index
Sets RESTORE Deseri​alise
SETEX Set with expiry (seconds)
SADD Add item SCAN Iterate keys
SETNX Set if doesn't exist
SCARD Get size SORT Get or store sorted copy of
SETRANGE Set substring list, set or sorted set
SDIFF Get difference
STRLEN Get length TTL Get item time to live
SDIFFSTORE Store difference
Strings can be used as numbers, arrays, bit TYPE Get type of item
SINTER Inters​ection
sets and binary data
SINTERSTORE Store inters​ection

Lists SISMEMBER Check for item

SMEMBERS Get all


BLPOP Blocking left pop
SMOVE Move item to another set
BRPOP Blocking right pop
SPOP Pop random item
BRPOPLPUSH Blocking rotate
SRANDMEMBER Get random item
LINDEX Access by index
SREM Remove matching
LINSERT Insert next to
SSCAN Iterate items
LLEN Get length
SUNION Union
LPOP Pop from start
SUNIONSTORE Store union

By James Hopkin (tasjaevan) Published 8th May, 2014. Sponsored by Readability-Score.com


cheatography.com/tasjaevan/ Last updated 10th November, 2015. 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 ZLEXRANGE Get items within

EVALSHA Run cached lexico​gra​phical


range
SCRIPT EXISTS Check by hash
ZRANGEBYSCORE Get items within
SCRIPT FLUSH Clear cache
score range
SCRIPT KILL Kill running script
ZRANK Get item rank
SCRIPT LOAD Add to cache
ZREM Remove item(s)
Lua scripts access keys through the array ZREMRANGEBYLEX Remove items
KEYS and additional arguments through the within
array ARGV. lexico​gra​phical
range
Hashes
ZREMRANGEBYRANK Remove items
HDEL Delete item within rank range

HEXISTS Check for item ZREMRANGEBYSCORE Remove items


within score range
HGET Get item
ZREVRANGE ZRANGE in
HGETALL Return all items
reverse order
HINCRBY Add to integer value
ZREVRANGEBYSCORE ZRANGE​BYSCOR
HINCRBYFLOAT Add to float value E in reverse order
HKEYS Return all keys ZREVRANK ZRANK in reverse
HLEN Get number of items order

HMGET Get multiple items ZSCAN Iterate items

HMSET Set multiple items ZSCORE Get item score

HSCAN Iterate items ZUNIONSTORE Store union

HSET Set item Lexico​gra​phical commands require all items to


HSETNX Set item if doesn't exist have the same score

HVALS Return all values


HyperL​ogLogs

Sorted sets PFADD Add items

ZADD Add item PFCOUNT Get approx​imate size

ZCARD Get number of items PFMERGE Merge HyperL​ogLogs

ZCOUNT Number of items within score


range

ZINCRBY Add to score

ZINTERSTORE Store inters​ection

ZLEXCOUNT Lexico​gra​phical 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 10th November, 2015. Measure your website readability!
Page 2 of 2. https://readability-score.com

You might also like