Redis key
The Redis key command is used to manage redis keys.
Syntax
The basic syntax of the Redis key command is as follows:
redis 127.0.0.1:6379> COMMAND KEY_NAME
Example
redis 127.0.0.1:6379> SET w3ckey redis OK redis 127.0.0.1:6379> DEL w3ckey (integer) 1
In the above example, DEL is a command , w3ckey is a key. If the key is successfully deleted, (integer) 1 will be output after the command is executed, otherwise (integer) 0
Redis keys command
# will be output. ##The following table gives the basic commands related to Redis keys:Command and description | |
---|---|
DEL key | This command is used to delete the key when the key exists. |
DUMP key | Serialize the given key and return the serialized value. |
EXISTS key | Check whether the given key exists. |
EXPIRE key seconds | Set the expiration time for the given key. |
EXPIREAT key timestamp | EXPIREAT has a similar function to EXPIRE, and is used to set the expiration time for the key.
The difference is that the time parameter accepted by the EXPIREAT command is UNIX timestamp. |
PEXPIRE key milliseconds | Set the expiration time of the key in milliseconds. |
PEXPIREAT key milliseconds-timestamp | Set the timestamp of the key expiration time (unix timestamp) in milliseconds |
KEYS pattern | Find all keys that match the given pattern (pattern). |
MOVE key db | Move the key of the current database to the given database db. |
PERSIST key | Remove the expiration time of the key, and the key will be persisted. |
PTTL key | Returns the remaining expiration time of the key in milliseconds. |
TTL key | Returns the remaining survival time (TTL, time to live) of the given key in seconds. |
RANDOMKEY | Randomly returns a key from the current database. |
RENAME key newkey | Modify the name of the key |
RENAMENX key newkey | Only when newkey does not exist, rename the key to newkey. |
TYPE key | Returns the type of value stored in key. |