This topic describes the commands that are supported by ApsaraDB for Redis performance-enhanced instances. Performance-enhanced instances of ApsaraDB for Redis integrate with certain features of Tair, a distributed key-value storage system developed by Alibaba Group. Performance-enhanced instances support the commands supported by Community Edition as well as some new commands.

Newly supported command types

The following table lists the commands not supported by native Redis databases but supported by performance-enhanced instances. In the Type column, you can navigate to the topic that describes each type of commands. In the List of commands column, you can navigate to the table that lists each type of commands in this topic.

Table 1. Newly supported command types and descriptions
Command Syntax Description
Enhanced string commands For more information, see Table 2. These commands are developed to enhance the performance of Redis strings. You can run these commands to change or delete a value if it matches a specified value.
TairString commands For more information, see Table 3. Performance-enhanced instances integrate with Tair and support the TairString data type and related commands.
TairHash commands For more information, see Table 4. Performance-enhanced instances integrate Tair and support the TairHash data type and related commands.
TairGIS commands For more information, see Table 5. Performance-enhanced instances integrate Tair and support the TairGIS data type and related commands.
TairBloom commands For more information, see Table 6. Performance-enhanced instances integrate Tair and support the TairBloom data type and related commands.
TairDoc commands For more information, see Table 7. Performance-enhanced instances integrate Tair and support the TairDoc data type and related commands.

List of newly supported commands

The following tables list all commands unsupported by native Redis databases but supported by performance-enhanced instances. For more information about these commands, see the documents listed in the Type column of Table 1 in this topic.

Table 2. Enhanced commands supported by Redis strings
Command Syntax Description
CAS CAS <key> <oldvalue> <newvalue> Changes the value of a specified key to newvalue if the current value of the key matches the oldvalue parameter. If the current value of the key does not match the oldvalue parameter, the value is not changed.
Note CAS is only applicable to Redis strings. To change TairString values, use the EXCAS command.
CAD CAD <key> <value> Deletes a specified key if the current value of the key matches the oldvalue parameter. The key is not deleted if the current value of the key does not match the oldvalue parameter.
Note CAD is only applicable to Redis strings. To delete TairString keys, use the EXCAD command.
Table 3. TairString commands
Command Syntax Description
EXSET EXSET <key> <value> [EX time] [PX time] [EXAT time] [PXAT time] [NX | XX] [VER version | ABS version] Writes a value to a key.
EXGET EXGET <key> Retrieves the value and version number of a TairString.
EXSETVER EXSETVER <key> <version> Specifies the version number of a key.
EXINCRBY EXINCRBY <key> <num> [EX time] [PX time] [EXAT time] [EXAT time] [PXAT time] [NX | XX] [VER version | ABS version] [MIN minval] [MAX maxval] Increases or decreases the value of a TairString. The value of the num parameter must be of long type.
EXINCRBYFLOAT EXINCRBYFLOAT <key> <num> [EX time] [PX time] [EXAT time] [EXAT time] [PXAT time] [NX | XX] [VER version | ABS version] [MIN minval] [MAX maxval] Increases the value of a TairString that you want to manage. The num parameter specifies a value of double type.
EXCAS EXCAS <key> <newvalue> <version> Changes the value of a specified key only if the current version number of the key matches the specified version number. The current value and version number of the key are returned if the update fails.
EXCAD EXCAD <key> <version> Deletes a key if the current version number of the key matches the specified version number. An error message is returned if the operation fails.
DEL DEL <key> [key ...] Deletes one or more TairStrings.
Table 4. TairHash commands
Command Syntax Description
EXHSET EXHSET <key> <field> <value> [EX time] [EXAT time] [PX time] [PXAT time] [NX/XX] [VER/ABS version] [NOACTIVE] Adds a field to a specified TairHash. If the key does not exist, a new key holding a TairHash is created. If the specified field exists, this command overwrites the value of the field. When you run this command, the system uses the Passive Expire algorithm to expire and delete fields.
EXHMSET EXHMSET <key> <field> <value> [field value...] Sets specified fields to respective values in the TairHash. If the key does not exist, a new key holding a TairHash is created. If the field already exists, this command overwrites the value of the field. When you run this command, the system uses the Passive Expire algorithm to expire and delete fields.
EXHPEXPIREAT EXHPEXPIREAT <key> <field> <milliseconds-timestamp> [VER/ABS version] [NOACTIVE] Specifies the absolute expiration time of a field in a specified TairHash. Unit: milliseconds. When you run this command, the system uses the Passive Expire algorithm to expire and delete fields.
EXHPEXPIRE EXHPEXPIRE <key> <field> <milliseconds> [NOACTIVE] Specifies the absolute expiration time of a field in a specified TairHash. Unit: milliseconds. When you run this command, the system uses the Passive Expire algorithm to expire and delete fields.
EXHEXPIREAT EXHEXPIREAT <key> <field> <timestamp> [NOACTIVE] Specifies the absolute relative expiration time of a filed in a specified TairHash. Unit: seconds. When you run this command, the system uses the Passive Expire algorithm to expire and delete fields.
EXHEXPIRE EXHEXPIRE <key> <field> <seconds> [NOACTIVE] Specifies the relative expiration time of a filed in a specified TairHash. Unit: seconds. When you run this command, the system uses the Passive Expire algorithm to expire and delete fields.
EXHPTTL EXHPTTL <key> <field> Retrieves the remaining expiration time of a field in a specified TairHash. Unit: milliseconds. When you run this command, the system uses the Passive Expire algorithm to expire and delete fields.
EXHTTL EXHTTL <key> <field> Retrieves the remaining expiration time of a field in a specified TairHash. Unit: seconds. When you run this command, the system uses the Passive Expire algorithm to expire and delete fields.
EXHVER EXHVER <key> <field> Retrieves the current version number of a field in a specified TairHash if the key matches the specified key. When you run this command, the system uses the Passive Expire algorithm to expire and delete fields.
EXHSETVER EXHSETVER <key> <field> <version> Sets the current version number of a field in the specified TairHash if the key matches the specified key. When you run this command, the system uses the Passive Expire algorithm to expire and delete fields.
EXHINCRBY EXHINCRBY <key> <field> <num> [EX time] [EXAT time] [PX time] [PXAT time] [VER/ABS version] [MIN minval] [MAX maxval] Increases the value of a specified field by an integer if the key matches the specified key. If the specified key does not exist, a TairHash is created. If the specified field does not exist, this command adds the field and sets the value of the field to 0 before creating a TairHash. You can also run the EX, EXAT, PX, or PXAT command to specify the expiration time for the field. When you run this command, the system uses the Passive Expire algorithm to expire and delete fields.
EXHINCRBYFLOAT EXHINCRBYFLOAT <key> <field> <value> [EX time] [EXAT time] [PX time] [PXAT time] [VER/ABS version] [MIN minval] [MAX maxval] Increases a specified field value by a floating-point number in a TairHash if the key matches the specified key. If the specified key does not exist, a TairHash is created. If the specified field does not exist, this command adds the field and sets the value of the field to 0 before creating a TairHash. You can also run the EX, EXAT, PX, or PXAT command to specify the expiration time for the field. When you run this command, the system uses the Passive Expire algorithm to expire and delete fields.
EXHGET EXHGET <key> <field> Retrieves a value associated with the specified field in a TairHash. A value of nil is returned if the specified key or field does not exist. When you run this command, the system uses the Passive Expire algorithm to expire and delete fields.
EXHGETWITHVER EXHGETWITHVER <key> <field> Retrieves the value and version number of a field in the specified TairHash if the key matches the specified key. A value of nil is returned if the specified key or field does not exist. When you run this command, the system uses the Passive Expire algorithm to expire and delete fields.
EXHMGET EXHMGET <key> <field> [field ...] Retrieves multiple field values in TairHash data in each query if the key of the TairHash data matches the specified key. A value of nil is returned if the specified key or fields do not exist. When you run this command, the system uses the Passive Expire algorithm to expire and delete fields.
EXHMGETWITHVER EXHMGETWITHVER <key> <field> [field ...] Retrieves the values and version numbers of multiple fields in a specified TairHash if the key matches the specified key. A value of nil is returned if the specified key or fields do not exist. When you run this command, the system uses the Passive Expire algorithm to expire and delete fields.
EXHDEL EXHDEL <key> <field> <field> <field> ... Deletes a field from a specified TairHash. A value of 0 is returned if the specified key or field does not exist. A value of 1 is returned if the field is deleted. When you run this command, the system uses the Passive Expire algorithm to expire and delete fields.
EXHLEN EXHLEN <key> [noexp] Retrieves the number of fields in a TairHash if the key matches the specified key. The returned value may include the number of expired fields that have not been deleted. If you want to query only the number of fields that are not expired, you can specify the oexp parameter.
EXHEXISTS EXHEXISTS <key> <field> Checks whether a field exists in a TairHash if the key matches the specified key. When you run this command, the system uses the Passive Expire algorithm to expire and delete fields.
EXHSTRLEN EXHSTRLEN <key> <field> Retrieves the length of a field value in the TairHash if the key matches the specified key. When you run this command, the system uses the Passive Expire algorithm to expire and delete fields.
EXHKEYS EXHKEYS <key> Retrieves all fields in a TairHash if the key matches the specified key. The returned result filters out expired fields. To reduce response time, the system does not delete these expired fields when running this command.
EXHVALS EXHVALS <key> Retrieves all field values in the TairHash if the key matches the specified key. The returned result filters out expired fields. To reduce response time, the system does not delete these expired fields when running this command.
EXHGETALL EXHGETALL <key> Retrieves all fields and associated values in a TairHash if the key matches the specified key. The returned result filters out expired fields. To reduce response time, the system does not delete these expired fields when running this command.
EXHSCAN EXHSCAN <key> <op> <subkey> [MATCH pattern] [COUNT count] Scans TairHashes if the key matches the specified key. You can set the op parameter to values, such as >, >=, <, <=, ==, ^, or $. This op parameter specifies a scan method. You can also set the MATCH parameter to specify a regular expression and filter subkeys. The COUNT parameter limits the number of returned values. If you do not specify the COUNT parameter, the default value is set to 10. The returned result filters out expired fields. To reduce response time, the system does not delete these expired fields when running this command.
DEL DEL <key> [key ...] Deletes one or more TairHashes.
Table 5. TairGIS commands
Command Syntax Description
GIS.ADD GIS.ADD <area> <PolygonName> <POLYGON> [<PolygonName2> <POLYGON> ...] Adds one or more polygons to a specified area. The polygons are described in well-known text (WKT). You can specify one or more polygons.
Note WKT is a text markup language that you can use to represent vector geometry objects on a map and the spatial reference systems of spatial objects. WKT also allows you to perform transformations between spatial reference systems.
GIS.GET GIS.GET <area> <PolygonName> Retrieves the WKT information about a polygon in a specified area. The PolygonName parameter specifies the polygon name.
GIS.DEL GIS.DEL <area> <PolygonName> Deletes a polygon in a specified area. The PolygonName parameter specifies the polygon name.
GIS.SEARCH GIS.SEARCH <area> <POINT | LINESTRING | POLYGON> Queries a polygon that contains a specified point, line, or plane in a specified area. The name and WKT information of the polygon are returned.
GIS.CONTAINS GIS.CONTAINS <area> <POINT | LINESTRING | POLYGON> [WITHOUTWKT] Checks whether a polygon in a specified area contains a specified point, line, or plane. If you specify the WITHOUTWKT parameter, the WKT information of the polygon is not returned.
GIS.INTERSECTS GIS.INTERSECTS <area> <POINT | LINESTRING | POLYGON> Queries the intersection relationship between a polygon in a specified area and a specified point, line, or plane.
GIS.GETALL GIS.GETALL <area> [WITHOUTWKT] Queries all polygons in a specified area. If you specify the WITHOUTWKT parameter, the WKT information of the polygons is not returned.
DEL DEL <key> [key ...] Deletes one or more TairGISs.
Table 6. TairBloom commands
Command Syntax Description
BF.RESERVE BF.RESERVE <key> <error_rate> <capacity> Creates an empty TairBloom filter with a specified capacity. The error_rate parameter specifies the false positive rate of the TairBloom filter.
BF.ADD BF.ADD <key> <item> Adds an item to a TairBloom filter.
BF.MADD BF.ADD <key> <item> [item...] Adds multiple items to a TairBloom filter specified by the key.
BF.EXISTS BF.EXISTS <key> <item> Checks whether an item exists in a TairBloom filter specified by the key.
BF.MEXISTS BF.EXISTS <key> <item> [item...] Checks whether multiple items exist in a TairBloom filter.
BF.INSERT BF.INSERT <key> [CAPACITY cap] [ERROR error] [NOCREATE] ITEMS <item... > Adds multiple items to a TairBloom filter. You can specify the capacity and false positive rate and specify whether to create a TairBloom filter if the TairBloom filter does not exist.
BF.DEBUG BF.DEBUG <key> Retrieves the information about a TairBloom filter. The information includes the number of layers, the number of items at each layer, and the false positive rate.
DEL DEL <key> [key ...] Deletes one or more TairBlooms.
Note The items added to a TairBloom cannot be deleted from the TairBloom. You can run the DEL command to delete the TairBloom.
Table 7. TairDoc commands
Command Syntax Description
JSON.SET JSON.SET <key> <path> <json> [NX or XX] Writes a JSON value to a TairDoc path of a specified key. If the specified key does not exist, the path must be the root directory. If the specified key and path exist, the specified JSON value overwrites the current JSON value in the path.
JSON.GET JSON.GET <key> [PATH] [FORMAT <XML/YAML>] [ROOTNAME <root>] [ARRNAME <arr>] Retrieves JSON data from a TairDoc path of a specified key.
JSON.DEL JSON.DEL <key> [path] Deletes JSON data from a TairDoc path of a specified key. If the path is not specified, the key is deleted. This command does not take effect if the key or path does not exist.
JSON.TYPE JSON.TYPE <key> [path] Retrieves the type of JSON data from a TairDoc path of a specified key.
JSON.NUMINCRBY JSON.NUMINCRBY <key> [path] <value> Increases JSON data in a TairDoc path by a specified value. The path must exist, and both the JSON data and increased value must be of int or double type.
JSON.STRAPPEND JSON.STRAPPEND <key> [path] <json-string> Appends a string specified in json-string to the end of the string in a TairDoc path. If you do not specify the path, the root directory is used.
JSON.STRLEN JSON.STRLEN <key> [path] Retrieves the JSON value length in a TairDoc path. If you do not specify the path, the root directory is used.
JSON.ARRAPPEND JSON.ARRAPPEND <key> <path> <json> [<json> ...] Appends one or more JSON values to the end of an array in a TairDoc path.
JSON.ARRPOP JSON.ARRPOP <key> <path> [index] Removes an element specified by index from an array in a specified TairDoc path and return the removed element.
JSON.ARRINSERT JSON.ARRINSERT <key> <path> <index> <json> [<json> ...] Adds one or more JSON elements to an array in a TairDoc path. The index parameter specifies the position to which the JSON elements are added.
JSON.ARRLEN JSON.ARRLEN <key> [path] Retrieves the length of the array in a TairDoc path.
JSON.ARRTRIM JSON.ARRTRIM <key> <path> <start> <stop> Trims a JSON array in a TairDoc path. The start value and the stop value specify the range in which the JSON data is retained.
DEL DEL <key> [key ...] Deletes one or more TairDocs.

Other commands

Performance-enhanced instances of ApsaraDB for Redis Enterprise Edition support the same commands as Community Edition when the same architecture is used. For more information about the commands supported by different ApsaraDB for Redis editions and architectures, see Overview.