272 lines
43 KiB
ReStructuredText
272 lines
43 KiB
ReStructuredText
:original_name: dcs-ug-180522002.html
|
|
|
|
.. _dcs-ug-180522002:
|
|
|
|
Redis Command Compatibility
|
|
===========================
|
|
|
|
This section describes DCS's compatibility with Redis commands, including supported commands, disabled commands, unsupported scripts and commands of later Redis versions, and restrictions on command usage.
|
|
|
|
For more information about the command syntax, visit the `Redis official website <https://redis.io/commands>`__.
|
|
|
|
DCS for Redis instances support most Redis commands. Any client compatible with the Redis protocol can access DCS.
|
|
|
|
- For security purposes, some Redis commands are disabled in DCS. For details, see :ref:`Commands Disabled by DCS for Redis 3.0 <dcs-ug-180522002__section0341135531914>`.
|
|
- Some Redis commands have usage restrictions, which are described in :ref:`Other Command Usage Restrictions <dcs-ug-180522002__section834293511127>`.
|
|
- Some Redis commands are supported by cluster DCS instances for multi-key operations in the same slot. For details, see :ref:`Table 4 <dcs-ug-180522002__table7589193113396>`.
|
|
|
|
Commands Supported by DCS for Redis 3.0
|
|
---------------------------------------
|
|
|
|
The following lists commands supported by DCS for Redis 3.0.
|
|
|
|
.. note::
|
|
|
|
Commands available since later Redis versions are not supported by earlier versions. Run a command on redis-cli to check whether it is supported by DCS for Redis. If the message "(error) ERR unknown command" is returned, the command is not supported.
|
|
|
|
.. table:: **Table 1** Commands supported by DCS for Redis 3.0
|
|
|
|
+-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| Category | Command |
|
|
+===================================+=====================================================================================================================================================================================================+
|
|
| Key | DEL, DUMP, EXISTS, EXPIRE, MOVE, PERSISI, PTTL, RANDOMKEY, RENAME, RENAMENX, RESTORE, SORT, TTL, TYPE, SCAN, OBJIECT |
|
|
+-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| String | APPEND, BITCOUNT, BITOP, BITPOS, DECR, DECRBY, GET, GETRANGE, GETSET, INCR, INCRBY, INCRBYFLOAT, MGET, MSET, MSETNX, PSETEX, SET, SETBIT, SETEX, SETNX, SETRANGE, STRLEN |
|
|
+-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| Hash | HDEL, HEXISTS, HGET, HGETALL, HINCRBY, HINCRBYFLOAT, HKEYS, HMGET, HMSET, HSET, HSETNX, HVALS, HSCAN |
|
|
+-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| List | BLPOP, BRPOP, BRPOPLRUSH, LINDEX, LINSERT, LLEN, LPOP, LPUSHX, LRANGE, LREM, LSET, LTRIM, RPOP, RPOPLPU, RPOPLPUSH, RPUSH, RPUSHX |
|
|
| | |
|
|
| | .. note:: |
|
|
| | |
|
|
| | Proxy Cluster Redis 3.0 instances do not support **BLPOP**, **BRPOP**, and **BRPOPLRUSH** commands. |
|
|
+-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| Set | SADD, SCARD, SDIFF, SDIFFSTORE, SINTER, SINTERSTORE, SISMEMBER, SMEMBERS, SMOVE, SPOP, SRANDMEMBER, SREM, SUNION, SUNIONSTORE, SSCAN |
|
|
+-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| Sorted set | ZADD, ZCARD, ZCOUNT, ZINCRBY, ZRANGE, ZRANGEBYSCORE, ZRANK, ZREMRANGEBYRANK, ZREMRANGEBYCORE, ZREVRANGE, ZREVRANGEBYSCORE, ZREVRANK, ZSCORE, ZUNIONSTORE, ZINTERSTORE, ZSCAN, ZRANGEBYLEX |
|
|
+-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| HyperLogLog | PFADD, PFCOUNT, PFMERGE |
|
|
+-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| Pub/Sub | PSUBSCRIBE, PUBLISH, PUBSUB, PUNSUBSCRIBE, SUBSCRIBE, UNSUBSCRIBE |
|
|
+-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| Transaction | DISCARD, EXEC, MULTI, UNWATCH, WATCH |
|
|
+-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| Connection | AUTH, ECHO, PING, QUIT, SELECT |
|
|
+-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| Server | FLUSHALL, FLUSHDB, DBSIZE, TIME, INFO, KEYS, CLIENT KILL, CLIENT LIST, CLIENT GETNAME, CLIENT SETNAME, CONFIG GET, MONITOR, SLOWLOG, ROLE |
|
|
| | |
|
|
| | .. note:: |
|
|
| | |
|
|
| | - Proxy Cluster Redis 3.0 instances do not support CLIENT commands, including **CLIENT KILL**, **CLIENT GETNAME**, **CLIENT LIST**, **CLIENT SETNAME**, **CLIENT PAUSE**, and **CLIENT REPLY**. |
|
|
| | - Proxy Cluster Redis 3.0 instances do not support the **MONITOR** command. |
|
|
+-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| Scripting | EVAL, EVALSHA, SCRIPT EXISTS, SCRIPT FLUSH, SCRIPT KILL, SCRIPT LOAD |
|
|
+-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| Geo | GEOADD, GEOHASH, GEOPOS, GEODIST, GEORADIUS, GEORADIUSBYMEMBER |
|
|
+-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
.. _dcs-ug-180522002__section0341135531914:
|
|
|
|
Commands Disabled by DCS for Redis 3.0
|
|
--------------------------------------
|
|
|
|
Redis APIs of single-node and master/standby DCS instances are compatible with open-source Redis for data access. For ease of use and security purposes, some management operations cannot be initiated from a Redis client. Related commands are listed in :ref:`Table 2 <dcs-ug-180522002__table31856418216>`.
|
|
|
|
.. _dcs-ug-180522002__table31856418216:
|
|
|
|
.. table:: **Table 2** Redis commands disabled in single-node and master/standby Redis 3.0 instances
|
|
|
|
+----------------+------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| Command | Description |
|
|
+================+================================================================================================================================================+
|
|
| **Key** | |
|
|
+----------------+------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| MIGRATE | Transfers a key from one Redis instance to another. |
|
|
+----------------+------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| **Server** | |
|
|
+----------------+------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| SLAVEOF | Changes the replication settings of a replica on the fly. |
|
|
+----------------+------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| SHUTDOWN | Stops all the clients and quits the Redis process. |
|
|
+----------------+------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| LASTSAVE | Returns the time of the last successful data persistence to disk. |
|
|
+----------------+------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| DEBUG commands | Debugging command that should not be used by clients. |
|
|
+----------------+------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| COMMAND | Returns array reply of details about all Redis commands. |
|
|
+----------------+------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| SAVE | Performs a synchronous save on disk, producing a point in time snapshot of all the data inside the Redis instance, in the form of an RDB file. |
|
|
+----------------+------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| BGSAVE | Asynchronously saves the database on disk. |
|
|
+----------------+------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| BGREWRITEAOF | Starts an Append Only File (AOF) rewrite process. |
|
|
+----------------+------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
In additional to these commands, Proxy Cluster Redis 3.0 instances do not support the commands listed in :ref:`Table 3 <dcs-ug-180522002__table122021410155210>`.
|
|
|
|
.. _dcs-ug-180522002__table122021410155210:
|
|
|
|
.. table:: **Table 3** Redis commands disabled in Proxy Cluster Redis 3.0 instances
|
|
|
|
+-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| Command | Description |
|
|
+===================================+===========================================================================================================================================================================================================+
|
|
| **Server** | |
|
|
+-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| SYNC | An internal command used for full replication. |
|
|
+-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| PSYNC | An internal command used for partial replication. |
|
|
+-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| MONITOR | Streams back every command processed by the Redis server for debugging. |
|
|
+-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| CLIENT commands | CLIENT KILL, CLIENT GETNAME, CLIENT LIST, CLIENT SETNAME, CLIENT PAUSE, and CLIENT REPLY. |
|
|
+-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| OBJECT | Debugging command that should not be used by clients. |
|
|
+-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| ROLE | Returns the role of the instance node. |
|
|
+-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| **Transaction** | |
|
|
+-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| DISCARD | Flushes all previously queued commands in a transaction. |
|
|
+-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| EXEC | Executes all previously queued commands in a transaction. |
|
|
+-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| MULTI | Marks the start of a transaction block. |
|
|
+-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| UNWATCH | Flushes all the previously watched keys for a transaction. |
|
|
+-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| WATCH | Marks the given key or keys to be watched. If the key or keys are modified by other commands before WATCH is executed, the transaction is interrupted. |
|
|
+-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| **Connection** | |
|
|
+-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| SELECT | Selects the Redis database. Note: Parameters of the **SELECT** command can only be set to **0**. |
|
|
+-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| **Keys** | |
|
|
+-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| MOVE | Moves *key* of the currently selected database to the specified destination database. |
|
|
+-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| **Cluster** | |
|
|
+-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| CLUSTER | Used for cluster management. |
|
|
+-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| **codis** (Proxy Cluster) | |
|
|
+-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| TIME | Returns the current server time. |
|
|
+-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| SLOTSINFO | Returns the number of slots and the size of each slot in Redis. |
|
|
+-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| SLOTSDEL | Deletes all key-value pairs in multiple slots in Redis. |
|
|
+-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| SLOTSMGRTSLOT | Randomly migrates a key-value pair in a slot to the destination. |
|
|
+-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| SLOTSMGRTONE | Migrates a specified key-value pair to the destination. |
|
|
+-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| SLOTSCHECK | Checks whether slots meet the following consistency requirements: |
|
|
| | |
|
|
| | - All the keys in the slots have a corresponding value in the database. |
|
|
| | - All the keys in the database have a value in the corresponding slot. |
|
|
+-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| SLOTSMGRTTAGSLOT | Migrates all key-value pairs with the same tag as a randomly selected key in a slot. |
|
|
+-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| SLOTSMGRTTAGONE | Migrates all key-value pairs with the same tag as a specified key. |
|
|
+-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| **List** | |
|
|
+-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| BLPOP | The blocking version of **LPOP** because it blocks the connection when there are no elements to pop from any of the given lists until the specified timeout has expired or a non-empty element is popped. |
|
|
+-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| BRPOP | The blocking version of **RPOP** because it blocks the connection when there are no elements to pop from any of the given lists until the specified timeout has expired or a non-empty element is popped. |
|
|
+-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| BRPOPLPUSH | The blocking variant of **RPOPLPUSH**. When *source* contains elements, this command behaves exactly like **RPOPLPUSH**. |
|
|
+-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
Restricted Redis Commands
|
|
-------------------------
|
|
|
|
Some Redis commands are supported by cluster DCS instances for multi-key operations in the same slot. For details, see :ref:`Table 4 <dcs-ug-180522002__table7589193113396>`.
|
|
|
|
.. _dcs-ug-180522002__table7589193113396:
|
|
|
|
.. table:: **Table 4** Redis commands restricted in cluster DCS instances.
|
|
|
|
+-----------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| Category | Description |
|
|
+=================+===================================================================================================================================================================+
|
|
| **Set** | |
|
|
+-----------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| SINTER | Returns the members of the set resulting from the intersection of all the given sets. |
|
|
+-----------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| SINTERSTORE | Equal to **SINTER**, but instead of returning the result set, it is stored in *destination*. |
|
|
+-----------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| SUNION | Returns the members of the set resulting from the union of all the given sets. |
|
|
+-----------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| SUNIONSTORE | Equal to **SUNION**, but instead of returning the result set, it is stored in *destination*. |
|
|
+-----------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| SDIFF | Returns the members of the set resulting from the difference between the first set and all the successive sets. |
|
|
+-----------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| SDIFFSTORE | Equal to **SDIFF**, but instead of returning the result set, it is stored in *destination*. |
|
|
+-----------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| SMOVE | Moves **member** from the set at **source** to the set at *destination*. |
|
|
+-----------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| **Sorted Set** | |
|
|
+-----------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| ZUNIONSTORE | Computes the union of *numkeys* sorted sets given by the specified keys. |
|
|
+-----------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| ZINTERSTORE | Computes the intersection of *numkeys* sorted sets given by the specified keys. |
|
|
+-----------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| **HyperLogLog** | |
|
|
+-----------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| PFCOUNT | Returns the approximated cardinality computed by the HyperLogLog data structure stored at the specified variable. |
|
|
+-----------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| PFMERGE | Merges multiple HyperLogLog values into a unique value. |
|
|
+-----------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| **Key** | |
|
|
+-----------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| RENAME | Renames *key* to *newkey*. |
|
|
+-----------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| RENAMENX | Renames *key* to *newkey* if *newkey* does not yet exist. |
|
|
+-----------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| BITOP | Performs a bitwise operation between multiple keys (containing string values) and stores the result in the destination key. |
|
|
+-----------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| RPOPLPUSH | Returns and removes the last element (tail) of the list stored at source, and pushes the element at the first element (head) of the list stored at *destination*. |
|
|
+-----------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| **String** | |
|
|
+-----------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| MSETNX | Sets the given keys to their respective values. |
|
|
+-----------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
.. note::
|
|
|
|
While running commands that take a long time to run, such as **FLUSHALL**, DCS instances may not respond to other commands and change to the faulty state. After the command finishes executing, the instance will return to normal.
|
|
|
|
.. _dcs-ug-180522002__section834293511127:
|
|
|
|
Other Command Usage Restrictions
|
|
--------------------------------
|
|
|
|
**Key commands:**
|
|
|
|
In case of a large amount of cached data, running a **Keys** command may block the execution of other commands for a long time or occupy exceptionally large memory. Therefore, when running a **Keys** command, describe the exact pattern and do not use fuzzy **keys \***. **keys \*** can be used during commissioning or when the number of keys does not exceed 5 million. Otherwise, the service cannot run properly.
|
|
|
|
**Server commands:**
|
|
|
|
- While running commands that take a long time to run, such as **FLUSHALL**, DCS instances may not respond to other commands and change to the faulty state. After the command finishes executing, the instance will return to normal.
|
|
- When the **FLUSHDB** or **FLUSHALL** command is run, execution of other service commands may be blocked for a long time in case of a large amount of cached data.
|
|
|
|
**EVAL and EVALSHA commands:**
|
|
|
|
- When the **EVAL** or **EVALSHA** command is run, at least one key must be contained in the command parameter. Otherwise, the error message "ERR eval/evalsha numkeys must be bigger than zero in redis cluster mode" is displayed.
|
|
- When the **EVAL** or **EVALSHA** command is run, a cluster DCS Redis instance uses the first key to compute slots. Ensure that the keys to be operated in your code are in the same slot. For details, visit http://redis.io/commands.
|
|
- For the **EVAL** command:
|
|
|
|
- You are advised to learn the Lua script features of Redis before running the **EVAL** command. For details, see https://redis.io/commands/eval.
|
|
- The execution timeout time of a Lua script is 5 seconds. Time-consuming statements such as long-time sleep and large loop statements should be avoided.
|
|
- When calling a Lua script, do not use random functions to specify keys. Otherwise, the execution results are inconsistent on the master and standby nodes.
|
|
|
|
**Others:**
|
|
|
|
- The time limit for executing a Redis command is 15 seconds. To prevent other services from failing, a master/replica switchover will be triggered after the command execution times out.
|
|
|
|
- Proxy Cluster DCS Redis instances created before July 10, 2018 must be upgraded to support the following commands:
|
|
|
|
SINTER, SDIFF, SUNION, PFCOUNT, PFMERGE, SINTERSTORE, SUNIONSTORE, SDIFFSTORE, SMOVE, ZUNIONSTORE, ZINTERSTORE, EVAL, EVALSHA, BITOP, RENAME, RENAMENX, RPOPLPUSH, MSETNX, SCRIPT LOAD, SCRIPT KILL, SCRIPT EXISTS, SCRIPT FLUSH.
|