90
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.
Here, “DEL” is a Redis command while “tutoraspire” 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