English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
Redis key commands are used to manage keys in redis.
The basic syntax of Redis key commands is as follows:
redis 127.0.0.1:6379> COMMAND KEY_NAME
redis 127.0.0.1:6379> SET w3codeboxkey redis OK redis 127.0.0.1:6379> DEL w3codeboxkey (integer) 1
In the above examples DEL It is a command, w3codeboxkey It is a key. If the key is deleted successfully, the command will output after execution (integer) 1Otherwise, it will output (integer) 0
The following table lists the basic commands related to Redis keys:
Serial number | Command and description |
---|---|
1 | DEL key This command is used to delete the key when the key exists. |
2 | DUMP key Serialize the given key and return the serialized value. |
3 | EXISTS key Check if the given key exists. |
4 | EXPIRE key seconds Set the expiration time for the given key, measured in seconds. |
5 | EXPIREAT key timestamp The function of EXPIREAT is similar to that of EXPIRE, both are used to set an expiration time for keys. The difference lies in that the EXPIREAT command accepts a time parameter in UNIX timestamp format. |
6 | PEXPIRE key milliseconds Sets the expiration time of the key in milliseconds. |
7 | PEXPIREAT key milliseconds-timestamp Sets the key's expiration time timestamp (unix timestamp) in milliseconds. |
8 | KEYS pattern Finds all keys that match the given pattern (pattern). |
9 | MOVE key db Moves the key in the current database to the specified database db. |
10 | PERSIST key Removes the expiration time of the key, and the key will be kept permanently. |
11 | PTTL key Returns the remaining expiration time of the key in milliseconds. |
12 | TTL key Returns the remaining time to live (TTL, time to live) of the given key in seconds. |
13 | RANDOMKEY Returns a random key from the current database. |
14 | RENAME key newkey Changes the name of the key. |
15 | RENAMENX key newkey Renames the key to newkey only if newkey does not exist. |
16 | SCAN cursor [MATCH pattern] [COUNT count] Iterates over the database keys in the database. |
17 | TYPE key Returns the type of the stored value of the key. |
For more commands, please refer to:https://redis.io/commands