Redis command o...login
Redis command operation Chinese manual
author:php.cn  update time:2022-04-12 14:07:28

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:

Serial numberCommand and description1DEL key2DUMP key 3EXISTS key 4EXPIRE key seconds5EXPIREAT key timestamp 6PEXPIRE key milliseconds 7PEXPIREAT key milliseconds-timestamp 8KEYS pattern 9MOVE key db 10PERSIST key 11PTTL key 12TTL key 13RANDOMKEY 14RENAME key newkey 15RENAMENX key newkey 16TYPE key
This command is used to delete the key when the key exists.
Serialize the given key and return the serialized value.
Check whether the given key exists.
Set the expiration time for the given key.
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.
Set the expiration time of the key in milliseconds.
Set the timestamp of the key expiration time (unix timestamp) in milliseconds
Find all keys that match the given pattern (pattern).
Move the key of the current database to the given database db.
Remove the expiration time of the key, and the key will be persisted.
Returns the remaining expiration time of the key in milliseconds.
Returns the remaining survival time (TTL, time to live) of the given key in seconds.
Randomly returns a key from the current database.
Modify the name of the key
Only when newkey does not exist, rename the key to newkey.
Returns the type of value stored in key.
For more commands, please refer to: http://redis.readthedocs.org/en/latest/