Redis Keys

Redis Keys are used with Redis command to manage themselves. See the syntax of using Redis keys with commands.

Syntax:

Example

Let's take an example of Redis key using with Redis DEL command. It will give an output 1, if the key is deleted otherwise it will be 0.

Redis Keys 1

Here, "DEL" is a Redis command while "javatpoint" is a key.


Redis Keys with Commands

IndexCommandDescription
1DEL keyThis command is used to delete the key, if it exists.
2DUMP keyThis command is used to return a serialized version of the value stored at the specified key.
3EXISTS keyThis command is used to check whether the key exists or not.
4EXPIRE keyThis command is used to set the expiry of the key after the specified time in seconds.
5EXPIREAT keyThis command is used to set the expiry of the key after the specified time. Here time is in UNIX timestamp format.
6PEXPIRE keyThis command is used to set the expiry of key in milliseconds.
7PEXPIREAT keyThis command is used to set the expiry of the key in UNIX timestamp specified as milliseconds.
8KEYS patternThis command is used to find all keys matching the specified pattern.
9MOVE keyIt is used to move a key to another database.
10PERSIST keyIt is used to remove the expiration from the key.
11PTTL keyIt is used to retrieve the remaining time in keys expiry in milliseconds.
12TTL keyIt is used to retrieve the remaining time in keys expiry.
13randomkeyIt is used to get a random key from Redis.
14RENAME key newkeyIt is used to change the key name.
15RENAMENX key newkeyIt is used to rename the key, if a new key doesn't exist.
16TYPE keyIt is used to fetch the data type of the value stored in the key.
Next TopicRedis Strings




Latest Courses