Redis Keys – Commands to manage keys in redis datastore

1 week ago Lalit Bhagtani 0

In Redis, Keys are used as a unique identifier to store, manage and retrieved a value stored in the database. Keys can be manage by using Redis Commands in redis-cli. The syntax for using redis Key commands is as follows :-

Syntax :-

redis host:post> <Command Name> <key name>

Example :-

Redis Keys

Redis Key Commands :- 

Some of the important commands to manage Keys in redis database are as follows :-

S.No Command Description
1 DEL Deletes the key, if it exists
2 DUMP Returns serialized version of value store at specified key
3 EXISTS Checks whether key exists or not
4 EXPIRE Set expiration time of the key
5 EXPRIEAT Set expiration time of the key in Unix Timestamp
6 PEXPIRE Set expiration time of the key in milliseconds
7 PEXPIREAT Set expiration time of the key in Unix Timestamp, specified in milliseconds
8 KEYS Find all the keys, which match the specified pattern
9 MOVE Moves a key to another database
10 PERSIST Removes expiration time from the key
11 PTTL Returns remaining time left in expiration of key, in milliseconds
12 TTL Returns remaining time left in expiration of key, in seconds
13 RANDOMKEY Returns a random key stored in datastore
14 RENAME Rename the key
15 RENAMENX Rename the key, if key with new name doesn’t exist
16 TYPE Returns datatype of value stored at the key

 

References :-

  1. Key Command Docs

That’s all for Redis Key and commands used to store and manage it in redis datastore. If you liked it, please share your thoughts in comments section and share it with others too.