Redis Keys are used with Redis command to control themselves. See the syntax of the usage of Redis keys with commands.
Syntax:
redis 127.0.0.1:6379> COMMAND KEY_NAME
Example
Let’s take an instance of Redis key the usage of with Redis DEL command. It will provide an output 1, if the key is deleted in any other case it will be 0
redis 127.0.0.1:6379> SET javatpoint redis
OK
redis 127.0.0.1:6379> DEL javatpoint
(integer) 1

Here, “DEL” is a Redis command while “javatpoint” is a key.
Redis Keys with Commands
Index | Command | Description |
---|---|---|
1 | DEL key | This command is used to delete the key, if it exists. |
2 | DUMP key | This command is used to return a serialized version of the value stored at the specified key. |
3 | EXISTS key | This command is used to check whether the key exists or not. |
4 | EXPIRE key | This command is used to set the expiry of the key after the specified time in seconds. |
5 | EXPIREAT key | This command is used to set the expiry of the key after the specified time. Here time is in UNIX timestamp format. |
6 | PEXPIRE key | This command is used to set the expiry of key in milliseconds. |
7 | PEXPIREAT key | This command is used to set the expiry of the key in UNIX timestamp specified as milliseconds. |
8 | KEYS pattern | This command is used to find all keys matching the specified pattern. |
9 | MOVE key | It is used to move a key to another database. |
10 | PERSIST key | It is used to remove the expiration from the key. |
11 | PTTL key | It is used to retrieve the remaining time in keys expiry in milliseconds. |
12 | TTL key | It is used to retrieve the remaining time in keys expiry. |
13 | randomkey | It is used to get a random key from Redis. |
14 | RENAME key newkey | It is used to change the key name. |
15 | RENAMENX key newkey | It is used to rename the key, if a new key doesn’t exist. |
16 | TYPE key | It is used to fetch the data type of the value stored in the key. |
Next TopicRedis Strings
Leave a Review