common_intro
COMMON Introduction
Apply for Redis Developer Course
|
Redis Regular Inspection / Technical Support
|
Redis Enterprise Server
|
|---|
Introduction
Common Keys
Commands under Common apply to all keys regardless of the 6 data types.
DEL originally belongs to Common, but it is placed under Strings for convenience of explanation.
TYPE added
From redisGate Enterprise ver 8.1.1 (ent811), a type option was added to Common Keys commands.
🟢 Reason: Previously all keys were stored and managed in a single dict (hash table).
The problem was that you could not know the key count by type.
For example, if there are 1 million keys total, with 500,000 strings, 100,000 lists, and 400,000 hashes,
you could not know the count by type. That made it hard to understand the key composition and workload.
For this reason, from ent811 the dict (hash table) was split into 6 by type.
📍 type: string/list/set/zset/hash/stream
🟡 Now when you use Common Keys commands such as exists, del, expire, and ttl, please specify the type
(string/list/set/zset/hash/stream) so Redis can tell which type the key belongs to.
You can still use them without specifying type, but Redis must search all 6 dicts (hash tables), so performance is lower.
➡ [Updated 2025.08.20(Wed)]
SORT command
A useful command that can sort data that is not already sorted, such as Lists or Sets.
You can also join with other keys to query.
While NoSQL products generally have no join, Redis SORT has a join feature.
Used well, you can get satisfying results.
Go to the SORT command description
Data (key) auto-expire Related commands
This is a data (key) auto-expire feature that RDBMS (relational database systems) do not have, but typical NoSQL products do.
With auto-expire, if you set a time on a key, the key is deleted automatically after that time.
You can set seconds or a specific time, and milliseconds are also possible.
This feature applies to keys only.
Key auto-expire Related commands:
EXPIRE,
EXPIREAT,
TTL,
PEXPIRE,
EXPIREAT,
PTTL,
PERSIST
Data (key) copy / move Related commands
Redis creates 16 DBs per instance by default. The command to move a key between DBs is
MOVE.
The command to copy/move a key between servers is MIGRATE.
Command summary
| Commands | Version | Syntax | Description |
|---|---|---|---|
| EXISTS | 1.0.0 | key | Check whether a key exists |
| UNLINK | 1.0.0 | key | Delete a key |
| RM | 6.1.0 | key (subquery) | Delete a key (Enterprise server) |
| KEYS | 1.0.0 | key pattern | Query keys by pattern |
| RENAME | 1.0.0 | key new_key | Rename a key |
| RENAMENX | 1.0.0 | key new_key | Rename a key only if new_key does not exist |
| EXPIRE | 1.0.0 | key seconds | Delete the key automatically after the specified seconds |
| RANDOMKEY | 1.0.0 | Query a random key | |
| SORT | 1.0.0 | key [BY pattern] [LIMIT offset count] [GET pattern [GET pattern ...]] [ASC|DESC] [ALPHA] [STORE destination] | Join with other keys, sort, and query |
| TTL | 1.0.0 | key | Query remaining expire time (seconds) |
| TYPE | 1.0.0 | key | Query the data type of a key |
| EXPIREAT | 1.2.0 | key timestamp | Delete the key automatically at the specified Unix timestamp |
| PERSIST | 2.2.0 | key | Remove expire time |
| OBJECT | 2.2.3 | subcommand key | Query information about a key |
| PEXPIRE | 2.6.0 | key milliseconds | Delete the key automatically after the specified milliseconds |
| PEXPIREAT | 2.6.0 | key milliseconds-timestamp | Delete the key automatically at the specified Unix milliseconds-timestamp |
| PTTL | 2.6.0 | key | Query remaining expire time in milliseconds |
| MOVE | 1.0.0 | key db | Move a key to another DB |
| DUMP | 2.6.0 | key | Dump data |
| RESTORE | 2.6.0 | key ttl serialized-value [REPLACE] | Restore data |
| MIGRATE | 2.6.0 | host port key destination-db timeout [COPY] [REPLACE] | Move/copy data to another Redis Server |
| SCAN | 2.8.0 | cursor [MATCH pattern] [COUNT count] | Query keys in batches of a given count |
Total : 22
Common keys command description
PDF manual
| << XINFO | COMMON Intro | EXISTS >> |
|---|
