Redis is an open-source, in-memory data structure store that is used as a database, cache, and message broker. It is designed to be fast, scalable, and reliable, making it a popular choice for many applications.
Redis is a key-value store, which means that data is stored as a key-value pair. The keys are unique identifiers that are used to retrieve the corresponding values. Redis supports a wide range of data types, including strings, hashes, lists, sets, and sorted sets.
Cheat Sheet
Command | Description |
---|---|
SET key value | Set the value of a key |
GET key | Get the value of a key |
DEL key | Delete a key |
EXPIRE key seconds | Set a key’s time to live in seconds |
TTL key | Get the remaining time to live of a key |
INCR key | Increment the integer value of a key by one |
DECR key | Decrement the integer value of a key by one |
INCRBY key increment | Increment the integer value of a key by a specified amount |
DECRBY key decrement | Decrement the integer value of a key by a specified amount |
APPEND key value | Append a value to a key |
STRLEN key | Get the length of the value of a key |
LPUSH key value | Insert a value at the beginning of a list |
RPUSH key value | Insert a value at the end of a list |
LPOP key | Remove and get the first element in a list |
RPOP key | Remove and get the last element in a list |
LINDEX key index | Get an element from a list by its index |
LLEN key | Get the length of a list |
SADD key member | Add a member to a set |
SREM key member | Remove a member from a set |
SMEMBERS key | Get all the members in a set |
SCARD key | Get the number of members in a set |
SISMEMBER key member | Check if a member is in a set |
ZADD key score member | Add a member to a sorted set with a score |
ZREM key member | Remove a member from a sorted set |
ZRANGE key start stop | Get a range of members from a sorted set by their index |
ZRANGEBYSCORE key min max | Get a range of members from a sorted set by their score |
ZCARD key | Get the number of members in a sorted set |
ZSCORE key member | Get the score of a member in a sorted set |
HSET key field value | Set the value of a field in a hash |
HGET key field | Get the value of a field in a hash |
HDEL key field | Delete a field in a hash |
HGETALL key | Get all the fields and values in a hash |
HLEN key | Get the number of fields in a hash |
PING | Ping the server |
FLUSHDB | Delete all the keys in the current database |
SELECT index | Select the database with the specified index |
INFO | Get information and statistics about the server |
QUIT | Close the connection to the server |
Reference: Redis Commands