SlideShare a Scribd company logo
Redis Cheat Sheet
Strings
APPEND key value Append
BITCOUNT key [ start
stop ]
Count # of set bits
BITOP AND dest [ src ]+ Bitwise AND
BITOP OR dest [ src ]+ Bitwise OR
BITOP XOR dest [ src ]+ Bitwise XOR
BITOP NOT dest src Bitwise NOT
BITPOS key bit [ start
stop ]
Find first set bit
DECR key Decrement integer
DECRBY key by Subtract from integer
GET key Get by key
GETBIT key offset Get bit by index
GETRANGE key start end Get substring
GETSET key value Set, returning old value
INCR key Increment integer
INCRBY key by Add to integer
INCRBYFLOAT key by Add to float
MGET [ key ]+ Get multiple
MSET [ key value ]+ Set multiple
MSETNX [ key value ]+ Set multiple if doesn’t exist
PSETEX key ms value Set with expiry (ms)
SET key value Set
SETBIT key offset value Set bit by index
SETEX key secs value Set with expiry (s)
SETNX key value Set if doesn’t exist
SETRANGE key offset
value
Set substring
STRLEN key Get length
Strings can be used as numbers, arrays, bit sets and binary data
Hashes
HDEL key [ field ]+ Delete field(s)
HEXISTS key field Check for field
HGET key field Get item
HGETALL key Return all fields / values
HINCRBY key field by Add to integer value
HINCRBYFLOAT key field by Add to float value
HKEYS key Return all fields
HLEN key Get number of fields
HMGET key [ field ]+ Get multiple items
HMSET key [ field value ]+ Set multiple items
HSCAN key cursor [ MATCH
pattern ] [ COUNT count ]
Iterate fields
HSET key field value Set field
HSETNX key field value Set field if doesn’t exist
HSTRLEN key field Get string length of field
HVALS key Return all values
Sets
SADD key [ member ]+ Add item
SCARD key Get size of set
SDIFF [ key ]+ Get difference
SDIFFSTORE dest [ key ]+ Store difference
SINTER [ key ]+ Intersection
SINTERSTORE dest [ key ]+ Store intersection
SISMEMBER key member Check for item
SMEMBERS key Get all
SMOVE src dest member Move item to another set
SPOP key [ count ]? Pop random item
SRANDMEMBER key [ count ] Get random item
SREM key [ member ]+ Remove matching
SSCAN key cursor [ MATCH
pattern ] [ COUNT count ]
Iterate items
SUNION[ key ]+ Union
SUNIONSTORE dest [ key ]+ Store union
Lists
BLPOP [ key ]+ timeout Blocking left pop
BRPOP [ key ]+ timeout Blocking right pop
BRPOPLPUSH src dest timeout Blocking rotate
LINDEX key index Access by index
LINSERT key BEFORE|AFTER
pivot value
Insert next to
LLEN key Get length
LPOP key Pop from start
LPUSH key [ value ]+ Push onto start
LPUSHX key value Push if list exists
LRANGE key start stop Access range
LREM key count value Remove occurrences
LSET key index value Set item by index
LTRIM list start stop Remove start/end items
RPOP key Pop from end
RPOPLPUSH src dest Rotate
RPUSH key [ value ]+ Push onto end
RPUSHX key value Push onto end if list exists
Databases
DEL [ key ]+ Delete item(s)
DUMP key Serialise item
EXISTS [ key ]+ Check for key
EXPIRE key s Set timeout on item
EXPIREAT key ts Set timeout by timestamp
KEYS pattern Get keys matching pattern
MIGRATE Transfer item between instances
MOVE key db Transfer item between databases
OBJECT Inspect item
PERSIST key Remove timeout
PEXPIRE key ms Set timeout (ms)
PEXPIREAT key ts Set timeout (timestamp)
PTTL key Get item TTL (ms)
RANDOMKEY Get random key
RENAME key new Change item’s key
RENAMENX key new Change key if new key doesn’t exist
RESTORE key Deserialise
SCAN key cursor
[ MATCH pattern ]
[ COUNT count ]
Iterate keys
SORT Get or store sorted copy
TTL key Get item TTL (s)
TYPE key Get type of item
Times are specified in seconds (s) or milliseconds (ms)
Timestamps (s) are specified as seconds since January 1, 1970
Sorted Sets
ZADD key [ options ]
[ score item ]+
Add item
ZCARD key Get number of items
ZCOUNT key min max Number of items with score range
ZINCRBY key incr member Add to score
ZINTERSTORE Store intersection
ZLEXCOUNT key min max Lexicographical range count
ZRANGE key start stop
[ WITHSCORES ]
Get items within rank range
ZRANGEBYLEX key min
max [ LIMIT offset count ]
Get items within lexicographical
range
ZRANGEBYSCORE key min
max [ WITHSCORES ]
[ LIMIT offset count ]
Get items within score range
ZRANK key member Get item rank
ZREM key [ member ]+ Remote item(s)
ZREMRANGEBYLEX key
min max
Remove items within
lexicographical range
ZREMRANGEBYRANK key
start stop
Remove items within rank range
ZREMRANGEBYSCORE key
min max
Remove items within score range
ZREVRANGE ZRANGE in reverse order
ZREVRANGEBYLEX ZRANGEBYLEX in reverse order
ZREVRANGEBYSCORE ZRANGEBYSCORE in reverse order
ZREVRANK ZRANK in reverse order
ZSCAN key cursor [ MATCH
pattern ] [ COUNT count ]
Iterate items
ZSCORE key member Get item score
ZUNIONSTORE dest
numkeys [ key ]+
[ WEIGHTS [ weight ]+ ]
[ AGGREGATE SUM|MIN|
MAX ]
Store union
Lexicographical commands require items to have the same score
Client/Server
AUTH password Request authentication
ECHO message Return message
PING Test connection
QUIT Close connection
SELECT index Set current database by index
Scripts
EVAL Run
EVALSHA Run cached
SCRIPT EXISTS Check by hash
SCRIPT FLUSH Clear cache
SCRIPT KILL Kill running script
SCRIPT LOAD Add to cache
About Redis Cheat Sheet - command line.docx

More Related Content

PDF
Redis Data Structures
PPTX
Redis - How to install, Keys and Lists commands
PDF
Try Redis - interactive Tutorial
PPTX
Redis 101 Data Structure
PDF
Php&redis presentation
PDF
Fosdem 2012 practical_indexing
PDF
Redis — memcached on steroids
PDF
WebCamp: Developer Day: The Big, the Small and the Redis - Андрей Савченко
Redis Data Structures
Redis - How to install, Keys and Lists commands
Try Redis - interactive Tutorial
Redis 101 Data Structure
Php&redis presentation
Fosdem 2012 practical_indexing
Redis — memcached on steroids
WebCamp: Developer Day: The Big, the Small and the Redis - Андрей Савченко

Similar to About Redis Cheat Sheet - command line.docx (20)

PPT
[Www.pkbulk.blogspot.com]file and indexing
PPT
PDF
DATASTORAGE.pdf
PDF
DATASTORAGE
PDF
DBMS 8 | Memory Hierarchy and Indexing
PDF
Introduction to Tokyo Products
PDF
Introduction to tokyo products
PPT
Data Indexing Presentation-My.pptppt.ppt
PPT
File organization 1
PDF
Redis 맛보기
PDF
quickguide-einnovator-9-redis
PDF
MySQL Index Cookbook
PDF
Indexing and-hashing
PPTX
DATASTORAGE.pptx
PPT
Introduction to redis
PDF
Indexes overview
PDF
Tech Talk Buscapé - Redis
PPTX
DBMS-Unit5-PPT.pptx important for revision
PDF
Developing polyglot persistence applications #javaone 2012
PDF
Developing polyglot persistence applications (SpringOne China 2012)
[Www.pkbulk.blogspot.com]file and indexing
DATASTORAGE.pdf
DATASTORAGE
DBMS 8 | Memory Hierarchy and Indexing
Introduction to Tokyo Products
Introduction to tokyo products
Data Indexing Presentation-My.pptppt.ppt
File organization 1
Redis 맛보기
quickguide-einnovator-9-redis
MySQL Index Cookbook
Indexing and-hashing
DATASTORAGE.pptx
Introduction to redis
Indexes overview
Tech Talk Buscapé - Redis
DBMS-Unit5-PPT.pptx important for revision
Developing polyglot persistence applications #javaone 2012
Developing polyglot persistence applications (SpringOne China 2012)
Ad

Recently uploaded (20)

PDF
ChatGPT for Dummies - Pam Baker Ccesa007.pdf
PPTX
UV-Visible spectroscopy..pptx UV-Visible Spectroscopy – Electronic Transition...
PDF
LDMMIA Reiki Yoga Finals Review Spring Summer
PDF
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
PPTX
A powerpoint presentation on the Revised K-10 Science Shaping Paper
PPTX
UNIT III MENTAL HEALTH NURSING ASSESSMENT
PPTX
CHAPTER IV. MAN AND BIOSPHERE AND ITS TOTALITY.pptx
PPTX
Chinmaya Tiranga Azadi Quiz (Class 7-8 )
PDF
احياء السادس العلمي - الفصل الثالث (التكاثر) منهج متميزين/كلية بغداد/موهوبين
PDF
Trump Administration's workforce development strategy
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PPTX
Unit 4 Skeletal System.ppt.pptxopresentatiom
PPTX
Lesson notes of climatology university.
PDF
Indian roads congress 037 - 2012 Flexible pavement
PDF
Empowerment Technology for Senior High School Guide
PPTX
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PPTX
Radiologic_Anatomy_of_the_Brachial_plexus [final].pptx
PDF
advance database management system book.pdf
PPTX
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
ChatGPT for Dummies - Pam Baker Ccesa007.pdf
UV-Visible spectroscopy..pptx UV-Visible Spectroscopy – Electronic Transition...
LDMMIA Reiki Yoga Finals Review Spring Summer
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
A powerpoint presentation on the Revised K-10 Science Shaping Paper
UNIT III MENTAL HEALTH NURSING ASSESSMENT
CHAPTER IV. MAN AND BIOSPHERE AND ITS TOTALITY.pptx
Chinmaya Tiranga Azadi Quiz (Class 7-8 )
احياء السادس العلمي - الفصل الثالث (التكاثر) منهج متميزين/كلية بغداد/موهوبين
Trump Administration's workforce development strategy
Supply Chain Operations Speaking Notes -ICLT Program
Unit 4 Skeletal System.ppt.pptxopresentatiom
Lesson notes of climatology university.
Indian roads congress 037 - 2012 Flexible pavement
Empowerment Technology for Senior High School Guide
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
Final Presentation General Medicine 03-08-2024.pptx
Radiologic_Anatomy_of_the_Brachial_plexus [final].pptx
advance database management system book.pdf
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
Ad

About Redis Cheat Sheet - command line.docx

  • 1. Redis Cheat Sheet Strings APPEND key value Append BITCOUNT key [ start stop ] Count # of set bits BITOP AND dest [ src ]+ Bitwise AND BITOP OR dest [ src ]+ Bitwise OR BITOP XOR dest [ src ]+ Bitwise XOR BITOP NOT dest src Bitwise NOT BITPOS key bit [ start stop ] Find first set bit DECR key Decrement integer DECRBY key by Subtract from integer GET key Get by key GETBIT key offset Get bit by index GETRANGE key start end Get substring GETSET key value Set, returning old value INCR key Increment integer INCRBY key by Add to integer INCRBYFLOAT key by Add to float MGET [ key ]+ Get multiple MSET [ key value ]+ Set multiple MSETNX [ key value ]+ Set multiple if doesn’t exist PSETEX key ms value Set with expiry (ms) SET key value Set SETBIT key offset value Set bit by index SETEX key secs value Set with expiry (s) SETNX key value Set if doesn’t exist SETRANGE key offset value Set substring STRLEN key Get length Strings can be used as numbers, arrays, bit sets and binary data Hashes HDEL key [ field ]+ Delete field(s) HEXISTS key field Check for field HGET key field Get item HGETALL key Return all fields / values HINCRBY key field by Add to integer value HINCRBYFLOAT key field by Add to float value HKEYS key Return all fields HLEN key Get number of fields HMGET key [ field ]+ Get multiple items HMSET key [ field value ]+ Set multiple items HSCAN key cursor [ MATCH pattern ] [ COUNT count ] Iterate fields HSET key field value Set field HSETNX key field value Set field if doesn’t exist HSTRLEN key field Get string length of field HVALS key Return all values Sets SADD key [ member ]+ Add item SCARD key Get size of set SDIFF [ key ]+ Get difference SDIFFSTORE dest [ key ]+ Store difference SINTER [ key ]+ Intersection SINTERSTORE dest [ key ]+ Store intersection SISMEMBER key member Check for item SMEMBERS key Get all SMOVE src dest member Move item to another set SPOP key [ count ]? Pop random item SRANDMEMBER key [ count ] Get random item SREM key [ member ]+ Remove matching SSCAN key cursor [ MATCH pattern ] [ COUNT count ] Iterate items SUNION[ key ]+ Union SUNIONSTORE dest [ key ]+ Store union Lists BLPOP [ key ]+ timeout Blocking left pop BRPOP [ key ]+ timeout Blocking right pop BRPOPLPUSH src dest timeout Blocking rotate LINDEX key index Access by index LINSERT key BEFORE|AFTER pivot value Insert next to LLEN key Get length LPOP key Pop from start LPUSH key [ value ]+ Push onto start LPUSHX key value Push if list exists LRANGE key start stop Access range LREM key count value Remove occurrences LSET key index value Set item by index LTRIM list start stop Remove start/end items RPOP key Pop from end RPOPLPUSH src dest Rotate RPUSH key [ value ]+ Push onto end RPUSHX key value Push onto end if list exists
  • 2. Databases DEL [ key ]+ Delete item(s) DUMP key Serialise item EXISTS [ key ]+ Check for key EXPIRE key s Set timeout on item EXPIREAT key ts Set timeout by timestamp KEYS pattern Get keys matching pattern MIGRATE Transfer item between instances MOVE key db Transfer item between databases OBJECT Inspect item PERSIST key Remove timeout PEXPIRE key ms Set timeout (ms) PEXPIREAT key ts Set timeout (timestamp) PTTL key Get item TTL (ms) RANDOMKEY Get random key RENAME key new Change item’s key RENAMENX key new Change key if new key doesn’t exist RESTORE key Deserialise SCAN key cursor [ MATCH pattern ] [ COUNT count ] Iterate keys SORT Get or store sorted copy TTL key Get item TTL (s) TYPE key Get type of item Times are specified in seconds (s) or milliseconds (ms) Timestamps (s) are specified as seconds since January 1, 1970 Sorted Sets ZADD key [ options ] [ score item ]+ Add item ZCARD key Get number of items ZCOUNT key min max Number of items with score range ZINCRBY key incr member Add to score ZINTERSTORE Store intersection ZLEXCOUNT key min max Lexicographical range count ZRANGE key start stop [ WITHSCORES ] Get items within rank range ZRANGEBYLEX key min max [ LIMIT offset count ] Get items within lexicographical range ZRANGEBYSCORE key min max [ WITHSCORES ] [ LIMIT offset count ] Get items within score range ZRANK key member Get item rank ZREM key [ member ]+ Remote item(s) ZREMRANGEBYLEX key min max Remove items within lexicographical range ZREMRANGEBYRANK key start stop Remove items within rank range ZREMRANGEBYSCORE key min max Remove items within score range ZREVRANGE ZRANGE in reverse order ZREVRANGEBYLEX ZRANGEBYLEX in reverse order ZREVRANGEBYSCORE ZRANGEBYSCORE in reverse order ZREVRANK ZRANK in reverse order ZSCAN key cursor [ MATCH pattern ] [ COUNT count ] Iterate items ZSCORE key member Get item score ZUNIONSTORE dest numkeys [ key ]+ [ WEIGHTS [ weight ]+ ] [ AGGREGATE SUM|MIN| MAX ] Store union Lexicographical commands require items to have the same score Client/Server AUTH password Request authentication ECHO message Return message PING Test connection QUIT Close connection SELECT index Set current database by index Scripts EVAL Run EVALSHA Run cached SCRIPT EXISTS Check by hash SCRIPT FLUSH Clear cache SCRIPT KILL Kill running script SCRIPT LOAD Add to cache