Latest web development tutorials

Redis key (key)

Redis key commands for managing redis keys.

grammar

The basic syntax Redis key command is as follows:

redis 127.0.0.1:6379> COMMAND KEY_NAME

Examples

redis 127.0.0.1:6379> SET w3bigkey redis
OK
redis 127.0.0.1:6379> DEL w3bigkey
(integer) 1

In the example above is aDEL command,w3bigkey is a bond. If the key is removed successfully, command execution output(integer) 1, otherwise the output (integer) 0


Redis keys command

The following table shows the basic commands associated with the Redis key:

No. Command and description
1 DEL key
This command is used to delete key when the key presence.
2 DUMP key
The sequence of a given key, and return the serialized value.
3 EXISTS key
Checks if the given key exists.
4 Key the EXPIRE seconds The
For a given key set an expiration time.
5 EXPIREAT key timestamp
EXPIREAT EXPIRE similar role and are used to set the expiration time for the key. Except that time parameters EXPIREAT accepted command is a UNIX timestamp (unix timestamp).
6 PEXPIRE key milliseconds
Setting key expiration time in milliseconds.
7 PEXPIREAT key milliseconds-timestamp
Setting key expiration timestamp (unix timestamp) in milliseconds
8 KEYS pattern
Find all match a given pattern (pattern) of the key.
9 MOVE key db
The key to move the current database to a given database db them.
10 PERSIST key
Remove key expiration time, key will endure.
11 PTTL key
In milliseconds return key remaining expiration time.
12 TTL key
In seconds, return the given key remaining time to live (TTL, time to live).
13 RANDOMKEY
From the current database returns a random key.
14 RENAME key newkey
Modify the name of the key
15 RENAMENX key newkey
Only when newkey does not exist, the key renamed newkey.
16 TYPE key
Type of return value of the stored key.

For more commands, see: http://redis.readthedocs.org/en/latest/index.html