-
Notifications
You must be signed in to change notification settings - Fork 0
Redis
Dhruv Singh edited this page Jun 12, 2024
·
2 revisions
- Redis is an open source, BSD licensed, advanced key-value store.
- It is often referred to as a data structure server, since the keys can contain strings, hashes, lists, sets and sorted sets.
- Redis is written in C.
- Redis holds its database entirely in the memory, using the disk only for persistence.
- Redis has a relatively rich set of data types when compared to many key-value data stores.
- Redis can replicate data to any number of slaves.
- All Redis operations are atomic, which ensures that if two clients concurrently access, Redis server will receive the updated value.
redis-cli
This will connect to your local server and now you can run any command.
redis-cli -h host -p port -a password
To run commands on Redis remote server.
-
DEL key
This command deletes the key, if it exists. -
DUMP key
This command returns a serialized version of the value stored at the specified key. -
EXISTS key
This command checks whether the key exists or not. -
EXPIRE key seconds
Sets the expiry of the key after the specified time. -
EXPIREAT key timestamp
Sets the expiry of the key after the specified time. Here time is in Unix timestamp format. -
PEXPIRE key milliseconds
Set the expiry of key in milliseconds. -
PEXPIREAT key milliseconds-timestamp
Sets the expiry of the key in Unix timestamp specified as milliseconds. -
KEYS pattern
Finds all keys matching the specified pattern. -
MOVE key db
Moves a key to another database. -
PERSIST key
Removes the expiration from the key. -
PTTL key
Gets the remaining time in keys expiry in milliseconds. -
TTL key
Gets the remaining time in keys expiry. -
RANDOMKEY
Returns a random key from Redis. -
RENAME key newkey
Changes the key name. -
RENAMENX key newkey
Renames the key, if a new key doesn't exist. -
TYPE key
Returns the data type of the value stored in the key.
-
SET key value
This command sets the value at the specified key. -
GET key
Gets the value of a key. -
GETRANGE key start end
Gets a substring of the string stored at a key. -
GETSET key value
Sets the string value of a key and returns its old value. -
GETBIT key offset
Returns the bit value at the offset in the string value stored at the key. -
MGET key1 [key2..]
Gets the values of all the given keys. -
SETBIT key offset value
Sets or clears the bit at the offset in the string value stored at the key. -
SETEX key seconds value
Sets the value with the expiry of a key. -
SETNX key value
Sets the value of a key, only if the key does not exist. -
SETRANGE key offset value
Overwrites the part of a string at the key starting at the specified offset. -
STRLEN key
Gets the length of the value stored in a key. -
MSET key value [key value ...]
Sets multiple keys to multiple values. -
MSETNX key value [key value ...]
Sets multiple keys to multiple values, only if none of the keys exist. -
PSETEX key milliseconds value
Sets the value and expiration in milliseconds of a key. -
INCR key
Increments the integer value of a key by one. -
INCRBY key increment
Increments the integer value of a key by the given amount. -
INCRBYFLOAT key increment
Increments the float value of a key by the given amount. -
DECR key
Decrements the integer value of a key by one. -
DECRBY key decrement
Decrements the integer value of a key by the given number. -
APPEND key value
Appends a value to a key.