Redis Keys
Redis key commands are used to manage Redis keys.
Syntax
The basic syntax of Redis key commands is as follows:
redis 127.0.0.1:6379> COMMAND KEY_NAME
Examples
redis 127.0.0.1:6379> SET examplekey redis OK redis 127.0.0.1:6379> DEL examplekey (integer) 1
In the above example,DELis a command,examplekeyis a key.(integer) 1If the key is deleted successfully, the output after executing the command is(integer) 0
Redis Keys Commands
Redis Keys Commands
| No. | Command and Description |
|---|---|
| 1 | DEL key This command deletes a key when it exists. |
| 2 | DUMP key Serialize the given key and return the serialized value. |
| 3 | EXISTS key Check whether the given key exists. |
| 4 | EXPIRE key seconds Set an expiration time for the given key, in seconds. |
| 5 | EXPIREAT key timestamp The effect of EXPIREAT is similar to EXPIRE; both are used to set an expiration time for a key. The difference is that the time parameter accepted by the EXPIREAT command is a UNIX timestamp. |
| 6 | PEXPIRE key milliseconds Set the expiration time of a key in milliseconds. |
| 7 | PEXPIREAT key milliseconds-timestamp Set the timestamp (unix timestamp) of the key expiration time in milliseconds. |
| 8 | KEYS pattern Find all keys matching the given pattern. |
| 9 | MOVE key db Move a key from the current database to the given database db. |
| 10 | PERSIST key Remove the expiration time of a key; the key will be kept permanently. |
| 11 | PTTL key Return the remaining expiration time of a key in milliseconds. |
| 12 | TTL key Return the remaining time to live (TTL) of the given key in seconds. |
| 13 | RANDOMKEY Return a random key from the current database. |
| 14 | RENAME key newkey Change the name of a key |
| 15 | RENAMENX key newkey Rename the key to newkey only when newkey does not exist. |
| 16 | SCAN cursor [MATCH pattern] [COUNT count] Iterate over the keys in the database. |
| 17 | TYPE key Return the type of the value stored in the key. |
For more commands, please refer to:https://redis.io/commands
Other Extensions