This topic describes the commands supported by a TairHash.

Overview

A TairHash is a hash that allows you to specify the expiration time and version number of a field. TairHashes and Redis-native hashes support multiple commands and provide high performance in data processing. However, Redis-native hashes allow you to specify the expiration time of only keys. TairHashes allow you to specify the expiration time of keys and fields. You can also use TairHashes to specify versions of fields. The improved features of TairHashes allow you to simplify the business development in most scenarios. TairHashes use the active expire algorithm to check the expiration time of fields and delete expired fields. This process does not increase the database response time.

TairHashes have the following features:

  • The expiration time and version number for each field can be specified.
  • Fields support the active expiration and passive expiration algorithms.
  • TairHashes and Redis-native hashes use similar syntax.
  • TairHashes support efficient active expiration policies. However, this can increase memory consumption to some extent.
Warning TairHashes are different from Redis-native hashes. The commands that are supported by TairHashes and Redis-native hashes are not interchangeable.

Prerequisites

The following conditions must be met for TairHash commands to take effect:

Commands

Table 1. 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 key for the TairHash is created. If the field has an existing a value, this command overwrites the value of the field. When you run this command, the system uses the passive expiration algorithm to delete expired fields.
EXHMSET EXHMSET <key> <field> <value> [field value...] Sets specified fields to values in a TairHash that matches a specified key. If the key does not exist, a key for the TairHash is created. If the field has an existing value, this command overwrites the value of the field. When you run this command, fields are expired and deleted by using the passive expiration mechanism.
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, fields are expired and deleted by using the passive expiration mechanism.
EXHPEXPIRE EXHPEXPIRE <key> <field> <milliseconds> [NOACTIVE] Specifies the relative expiration time of a field in a TairHash that matches a specified key. Unit: milliseconds. When you run this command, fields are expired and deleted by using the passive expiration mechanism.
EXHEXPIREAT EXHEXPIREAT <key> <field> <timestamp> [NOACTIVE] Specifies the absolute expiration time of a field in a specified TairHash. Unit: seconds. When you run this command, fields are expired and deleted by using the passive expiration mechanism.
EXHEXPIRE EXHEXPIRE <key> <field> <seconds> [NOACTIVE] Specifies the relative expiration time of a field in a TairHash that matches a specified key. Unit: seconds. When you run this command, fields are expired and deleted by using the passive expiration mechanism.
EXHPTTL EXHPTTL <key> <field> Retrieves the remaining expiration time of a field in a specified TairHash. Unit: milliseconds. When you run this command, fields are expired and deleted by using the passive expiration mechanism.
EXHTTL EXHTTL <key> <field> Retrieves the remaining expiration time of a field in a specified TairHash. Unit: seconds. When you run this command, fields are expired and deleted by using the passive expiration mechanism.
EXHVER EXHVER <key> <field> Retrieves the current version number of a field in a specified TairHash. When you run this command, fields are expired and deleted by using the passive expiration mechanism.
EXHSETVER EXHSETVER <key> <field> <version> Sets the version number of a field in a specified TairHash. When you run this command, fields are expired and deleted by using the passive expiration mechanism.
EXHINCRBY EXHINCRBY <key> <field> <num> [EX time] [EXAT time] [PX time] [PXAT time] [VER/ABS version] [MIN minval] [MAX maxval] Increases the field value in a specified TairHash by an integer. 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 a TairHash is created. You can also run the EX, EXAT, PX, or PXAT command to specify the expiration time for the field. When you run this command, fields are expired and deleted by using the passive expiration mechanism.
Note To add a field that does not expire, you can run this command without the need to specify an expiration time.
EXHINCRBYFLOAT EXHINCRBYFLOAT <key> <field> <value> [EX time] [EXAT time] [PX time] [PXAT time] [VER/ABS version] [MIN minval] [MAX maxval] Increases the value of a field in a specified TairHash by a floating-point number. 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 a TairHash is created. You can also run the EX, EXAT, PX, or PXAT command to specify the expiration time for the field. When you run this command, fields are expired and deleted by using the passive expiration mechanism.
Note To add a field that does not expire, you can run this command without the need to specify an expiration time.
EXHGET EXHGET <key> <field> Retrieves the value of a specified field in a specified TairHash. If the specified key or field does not exist, a value of nil is returned. When you run this command, fields are expired and deleted by using the passive expiration mechanism.
EXHGETWITHVER EXHGETWITHVER <key> <field> Retrieves the value and version number of a field in a specified TairHash. If the specified key or field does not exist, a value of nil is returned. When you run this command, fields are expired and deleted by using the passive expiration mechanism.
EXHMGET EXHMGET <key> <field> [field ...] Retrieves multiple field values in a specified TairHash in each query if the key of a specified TairHash matches the specified key. If the specified key or field does not exist, a value of nil is returned. When you run this command, fields are expired and deleted by using the passive expiration mechanism.
EXHMGETWITHVER EXHMGETWITHVER <key> <field> [field ...] Retrieves the values and version numbers of multiple fields in a specified TairHash. If the specified key or field does not exist, a value of nil is returned. When you run this command, fields are expired and deleted by using the passive expiration mechanism.
EXHDEL EXHDEL <key> <field> <field> <field> ... Deletes a field from a specified TairHash. If the specified key or field does not exist, a value of 0 is returned. If the field is deleted, a value of 1 is returned. When you run this command, fields are expired and deleted by using the passive expiration mechanism.
EXHLEN EXHLEN <key> [noexp] Retrieves the number of fields in a specified TairHash. The returned value may include the number of expired fields that are not deleted. If you want to query only the number of fields that are not expired, you can set the noexp parameter.
EXHEXISTS EXHEXISTS <key> <field> Checks whether a field exists in a TairHash that matches a specified key. When you run this command, fields are expired and deleted by using the passive expiration mechanism.
EXHSTRLEN EXHSTRLEN <key> <field> Retrieves the length of a field value in a specified TairHash. When you run this command, fields are expired and deleted by using the passive expiration mechanism.
EXHKEYS EXHKEYS <key> Retrieves all fields in a specified TairHash. Expired fields are filtered out in the returned results. To reduce response time, the system does not delete the expired fields while the system runs the command.
EXHVALS EXHVALS <key> Retrieves all field values in a specified TairHash. Expired fields are filtered out in the returned results. To reduce response time, the system does not delete the expired fields while the system runs the command.
EXHGETALL EXHGETALL <key> Retrieves all fields and associated values in a specified TairHash. Expired fields are filtered out in the returned results. To reduce response time, the system does not delete the expired fields while the system runs the command.
EXHSCAN EXHSCAN <key> <op> <subkey> [MATCH pattern] [COUNT count] Scans TairHashes that match a specified key. You can set the op parameter to values such as >, >=, <, <=, ==, ^, and $. This op parameter specifies a scan method. You can also set the MATCH parameter to specify a regular expression and filter out subkeys. The COUNT parameter limits the number of returned values. If you do not set the COUNT parameter, the default value is set to 10. Expired fields are filtered out in the returned results. To reduce response time, the system does not delete the expired fields while the system runs the command.
DEL DEL <key> [key ...] Deletes one or more TairHashes.

EXHSET

  • Syntax

    EXHSET <key> <field> <value> [EX time] [EXAT time] [PX time] [PXAT time] [NX | XX] [VER/ABS version] [NOACTIVE]

  • Time complexity

    O(1)

  • Description

    This command is used to add a field to the TairHash that matches a specified key. If the key does not exist, a key for the TairHash is created. If the field has an existing value, this command overwrites the value of the field.

  • Parameters and options
    Parameter/option Description
    key The key of the TairHash that you want to manage.
    field An element of the TairHash. A TairHash key can be mapped to multiple fields.
    value The value of the specified field. A field can have only one value.
    EX The relative expiration time of the specified field. Unit: seconds. A value of 0 specifies that the field immediately expires. If this option is not specified, the field does not expire.
    EXAT The absolute expiration time of the specified field. Unit: seconds. A value of 0 specifies that the field immediately expires. If this option is not specified, the field does not expire.
    PX The relative expiration time of the specified field. Unit: milliseconds. A value of 0 specifies that the field immediately expires. If this option is not specified, the field does not expire.
    PXAT The absolute expiration time of the specified field. Unit: milliseconds. A value of 0 specifies that the field immediately expires. If this option is not specified, the field does not expire.
    NX Specifies that the value is written only if the field does not exist.
    XX Specifies that the value is written only if the field exists.
    VER The version number of the specified field.
    • If the specified field exists, the version number specified by this parameter is matched with the current version number:
      • If the version numbers match, the system continues running the command and increases the version number by 1.
      • If the version numbers do not match, an error message is returned.
    • If the specified field does not exist or the current version number of the field is 0, this parameter is ignored. The specified value is written to the field, and then the version number is set to 1.
    ABS The absolute version number of the field. If you set this parameter, the system forcibly writes the specified value to the field regardless of whether the field has a value. Then, the version number is set to the specified ABS value when a field is added.
    NOACTIVE When you set the EX, EXAT, PX, or PXAT parameter, you can set the NOACTIVE parameter to disable the active expiration policy for the field. This allows you to reduce the memory consumption.
  • Return values
    • 1: a new field is created and a value is set.
    • 0: the field has a value and the specified value overwrites the current value.
    • -1: the XX parameter is set but the specified field does not exist.
    • -1: the NX parameter is set and the specified field exists.
    • An error message that contains "ERR update version is stale" is returned. The message indicates that the value of the VER parameter does not match the current version number.
    • Otherwise, an exception is returned.

EXHGET

  • Syntax

    EXHGET <key> <field>

  • Time complexity

    O(1)

  • Description

    This command is used to retrieve a value associated with the specified field in a TairHash that matches a specified key.

  • Parameters and options
    Parameter/option Description
    key The key of the TairHash that you want to manage.
    field An element of the TairHash. A TairHash key can be mapped to multiple fields.
  • Return values
    • If the field exists and the operation is successful, the value of the field is returned.
    • nil: the key or field does not exist.
    • Otherwise, an exception is returned.

EXHMSET

  • Syntax

    EXHMSET <key> <field> <value> [field value...]

  • Time complexity

    O(1)

  • Description

    This command is used to set specified fields to values in a TairHash that matches a specified key. If the key does not exist, a key for the TairHash is created. If the field has an existing value, this command overwrites the value of the field.

  • Parameters and options
    Parameter/option Description
    key The key of the TairHash that you want to manage.
    field An element of the TairHash. A TairHash key can be mapped to multiple fields.
    value The value of the specified field. A field can have only one value.
  • Return values
    • If the operation is successful, OK is returned.
    • Otherwise, an exception is returned.

EXHPEXPIREAT

  • Syntax

    EXHPEXPIREAT <key> <field> <milliseconds-timestamp> [VER/ABS version] [NOACTIVE]

  • Time complexity

    O(1)

  • Description

    This command is used to specify the absolute expiration time of a field in a TairHash that matches a specified key. Unit: milliseconds.

  • Parameters and options
    Parameter/option Description
    key The key of the TairHash that you want to manage.
    field An element of the TairHash. A TairHash key can be mapped to multiple fields.
    milliseconds-timestamp The UNIX timestamp. Unit: milliseconds.
    VER The version number of the specified field.
    • If the specified field exists, the version number specified by this parameter is matched with the current version number:
      • If the version numbers match, the system continues running the command and increases the version number by 1.
      • If the version numbers do not match, an error message is returned.
    • If the specified field does not exist or the current version number of the field is 0, this parameter is ignored. The specified value is written to the field, and then the version number is set to 1.
    ABS The absolute version number of the field. If you set this parameter, the system forcibly writes the specified value to the field regardless of whether the field has a value. Then, the version number is overwritten with the specified ABS value.
    NOACTIVE When you set the EX, EXAT, PX, or PXAT parameter, you can set the NOACTIVE parameter to disable the active expiration policy for the field. This allows you to reduce the memory consumption.
  • Return values
    • 1: the field exists and a value is set.
    • 0: the field does not exist.
    • Otherwise, an exception is returned.

EXHPEXPIRE

  • Syntax

    EXHPEXPIRE <key> <field> <milliseconds> [VER/ABS version] [NOACTIVE]

  • Time complexity

    O(1)

  • Description

    This command is used to specify the relative expiration time of a field in a TairHash that matches a specified key. Unit: milliseconds.

  • Parameters and options
    Parameter/option Description
    key The key of the TairHash that you want to manage.
    field An element of the TairHash. A TairHash key can be mapped to multiple fields.
    milliseconds The relative expiration time of the specified field. Unit: milliseconds.
    VER The version number of the specified field.
    • If the specified field exists, the version number specified by this parameter is matched with the current version number:
      • If the version numbers match, the system continues running the command and increases the version number by 1.
      • If the version numbers do not match, an error message is returned.
    • If the specified field does not exist or the current version number of the field is 0, this parameter is ignored. The specified value is written to the field, and then the version number is set to 1.
    ABS The absolute version number of the field. If you set this parameter, the system forcibly writes the specified value to the field regardless of whether the field has a value. Then, the version number is overwritten with the specified ABS value.
    NOACTIVE When you set the EX, EXAT, PX, or PXAT parameter, you can set the NOACTIVE parameter to disable the active expiration policy for the field. This allows you to reduce the memory consumption.
  • Return values
    • 1: the field exists and a value is set.
    • 0: the field does not exist.
    • Otherwise, an exception is returned.

EXHEXPIREAT

  • Syntax

    EXHEXPIREAT <key> <field> <timestamp> [VER/ABS version] [NOACTIVE]

  • Time complexity

    O(1)

  • Description

    This command is used to specify the absolute expiration time of a field in a TairHash that matches a specified key. Unit: seconds.

  • Parameters and options
    Parameter/option Description
    key The key of the TairHash that you want to manage.
    field An element of the TairHash. A TairHash key can be mapped to multiple fields.
    timestamp The UNIX timestamp. Unit: seconds.
    VER The version number of the specified field.
    • If the specified field exists, the version number specified by this parameter is matched with the current version number:
      • If the version numbers match, the system continues running the command and increases the version number by 1.
      • If the version numbers do not match, an error message is returned.
    • If the specified field does not exist or the current version number of the field is 0, this parameter is ignored. The specified value is written to the field, and then the version number is set to 1.
    ABS The absolute version number of the field. If you set this parameter, the system forcibly writes the specified value to the field regardless of whether the field has a value. Then, the version number is overwritten with the specified ABS value.
    NOACTIVE When you set the EX, EXAT, PX, or PXAT parameter, you can set the NOACTIVE parameter to disable the active expiration policy for the field. This allows you to reduce the memory consumption.
  • Return values
    • 1: the field exists and a value is set.
    • 0: the field does not exist.
    • Otherwise, an exception is returned.

EXHEXPIRE

  • Syntax

    EXHEXPIRE <key> <field> <seconds>

  • Time complexity

    O(1)

  • Description

    This command is used to specify the relative expiration time of a field in a TairHash that matches a specified key. Unit: seconds.

  • Parameters and options
    Parameter/option Description
    key The key of the TairHash that you want to manage.
    field An element of the TairHash. A TairHash key can be mapped to multiple fields.
    seconds The relative expiration time of the specified field. Unit: seconds.
    VER The version number of the specified field.
    • If the specified field exists, the version number specified by this parameter is matched with the current version number:
      • If the version numbers match, the system continues running the command and increases the version number by 1.
      • If the version numbers do not match, an error message is returned.
    • If the specified field does not exist or the current version number of the field is 0, this parameter is ignored. The specified value is written to the field, and then the version number is set to 1.
    ABS The absolute version number of the field. If you set this parameter, the system forcibly writes the specified value to the field regardless of whether the field has a value. Then, the version number is overwritten with the specified ABS value.
    NOACTIVE When you set the EX, EXAT, PX, or PXAT parameter, you can set the NOACTIVE parameter to disable the active expiration policy for the field. This allows you to reduce the memory consumption.
  • Return values
    • 1: the field exists and a value is set.
    • 0: the field does not exist.
    • Otherwise, an exception is returned.

EXHPTTL

  • Syntax

    EXHPTTL <key> <field>

  • Time complexity

    O(1)

  • Description

    This command is used to retrieve the remaining expiration time of a field in a TairHash that matches a specified key. Unit: milliseconds.

  • Parameters and options
    Parameter/option Description
    key The key of the TairHash that you want to manage.
    field An element of the TairHash. A TairHash key can be mapped to multiple fields.
  • Return values
    • -2: the specified key or field does not exist.
    • -1: the specified field exists but the TTL value is not specified.
    • The expiration time of the field is returned if the field exists and the expiration time of the field is specified. Unit: milliseconds.
    • Otherwise, an exception is returned.

EXHTTL

  • Syntax

    EXHTTL <key> <field>

  • Time complexity

    O(1)

  • Description

    This command is used to retrieve the remaining expiration time of a field in a TairHash that matches a specified key. Unit: seconds.

  • Parameters and options
    Parameter/option Description
    key The key of the TairHash that you want to manage.
    field An element of the TairHash. A TairHash key can be mapped to multiple fields.
  • Return values
    • -2: the specified key or field does not exist.
    • -1: the specified field exists but the TTL value is not specified.
    • The expiration time of the field is returned if the field exists and the expiration time of the field is specified. Unit: seconds.
    • Otherwise, an exception is returned.

EXHVER

  • Syntax

    EXHVER <key> <field>

  • Time complexity

    O(1)

  • Description

    This command is used to retrieve the current version number of a field in a TairHash that matches a specified key.

  • Parameters and options
    Parameter/option Description
    key The key of the TairHash that you want to manage.
    field An element of the TairHash. A TairHash key can be mapped to multiple fields.
  • Return values
    • -1: the specified key does not exist.
    • -2: the specified field does not exist.
    • The version number of the specified field is returned if the operation is successful.
    • Otherwise, an exception is returned.

EXHSETVER

  • Syntax

    EXHSETVER <key> <field> <version>

  • Time complexity

    O(1)

  • Description

    This command is used to set the current version number of a field in a TairHash that matches a specified key.

  • Parameters and options
    Parameter/option Description
    key The key of the TairHash that you want to manage.
    field An element of the TairHash. A TairHash key can be mapped to multiple fields.
  • Return values
    • 0: the specified TairHash or field does not exist.
    • 1: the version number is specified.
    • Otherwise, an exception is returned.

EXHINCRBY

  • Syntax

    EXHINCRBY <key> <field> <num> [EX time] [EXAT time] [PX time] [PXAT time] [VER/ABS version] [MIN minval] [MAX maxval]

  • Time complexity

    O(1)

  • Description

    This command is used to increase the value of a field by num in a TairHash that matches a specified key. The value of the num parameter must be an integer. If the specified TairHash 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. When you run this command, the system uses the passive expiration algorithm to delete expired fields.

  • Parameters and options
    Parameter/option Description
    key The key of the TairHash that you want to manage.
    field An element of the TairHash. A TairHash key can be mapped to multiple fields.
    num The integer by which you want to increase a specified field value.
    EX The relative expiration time of the specified field. Unit: seconds.A value of 0 specifies that the field immediately expires. If this option is not specified, the field does not expire.
    EXAT The absolute expiration time of the specified field. Unit: seconds. A value of 0 specifies that the field immediately expires. If this option is not specified, the field does not expire.
    PX The relative expiration time of the specified field. Unit: milliseconds. A value of 0 specifies that the field immediately expires. If this option is not specified, the field does not expire.
    PXAT The absolute expiration time of the specified field. Unit: milliseconds. A value of 0 specifies that the field immediately expires. If this option is not specified, the field does not expire.
    VER The version number of the specified field.
    • If the specified field exists, the version number specified by this parameter is matched with the current version number:
      • If the version numbers match, the TairHash is increased by num and the version number is increased by 1.
      • If the version numbers do not match, an error message is returned.
    • If the value of the VER parameter is 0, you do not need to check the version number.
    ABS The absolute version number of the field. If you set this parameter, the system forcibly increases the TairHash by num regardless of whether the field has a value. Then, the version number is overwritten with the specified ABS value. The value of this parameter must not be 0.
    MIN The minimum value of the field. If the specified value is smaller than this lower limit, an exception is returned.
    MAX The maximum value of the field. If the specified value is larger than this upper limit, an exception is returned.
    NOACTIVE When you set the EX, EXAT, PX, or PXAT parameter, you can set the NOACTIVE parameter to disable the active expiration policy for the field. This allows you to reduce the memory consumption.
    Note To add a field that does not expire, you can run this command without the need to specify an expiration time.
  • Return values
    • The value increased by num is returned if the operation is successful.
    • Otherwise, an exception is returned.

EXHINCRBYFLOAT

  • Syntax

    EXHINCRBYFLOAT <key> <field> <num> [EX time] [EXAT time] [PX time] [PXAT time] [VER/ABS version] [MIN minval] [MAX maxval]

  • Time complexity

    O(1)

  • Description

    This command is used to increase a specified field value by num in a TairHash that matches a specified key. The value of the num parameter must be a floating-point number. If the specified TairHash 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. When you run this command, the system uses the passive expiration algorithm to delete expired fields.

  • Parameters and options
    Parameter/option Description
    key The key of the TairHash that you want to manage.
    field An element of the TairHash. A TairHash key can be mapped to multiple fields.
    num The increment (a floating-point number) to be added to the specified field value.
    EX The relative expiration time of the specified field. Unit: seconds. A value of 0 specifies that the field immediately expires. If this option is not specified, the field does not expire.
    EXAT The absolute expiration time of the specified field. Unit: seconds. A value of 0 specifies that the field immediately expires. If this option is not specified, the field does not expire.
    PX The relative expiration time of the specified field. Unit: milliseconds. A value of 0 specifies that the field immediately expires. If this option is not specified, the field does not expire.
    PXAT The absolute expiration time of the specified field. Unit: milliseconds.A value of 0 specifies that the field immediately expires. If this option is not specified, the field does not expire.
    VER The version number of the specified field.
    • If the specified field exists, the version number specified by this parameter is matched with the current version number:
      • If the version numbers match, the TairHash is increased by num and the version number is increased by 1.
      • If the version numbers do not match, an error message is returned.
    • If the value of the VER parameter is 0, you do not need to check the version number.
    ABS The absolute version number of the field. If you set this parameter, the system forcibly increases the TairHash by num regardless of whether the field has a value. Then, the version number is overwritten with the specified ABS value. The value of this parameter must not be 0.
    MIN The minimum value of the field. If the specified value is smaller than this lower limit, an exception is returned.
    MAX The maximum value of the field. If the specified value is larger than this upper limit, an exception is returned.
    NOACTIVE When you set the EX, EXAT, PX, or PXAT parameter, you can set the NOACTIVE parameter to disable the active expiration policy for the field. This allows you to reduce the memory consumption.
    Note To add a field that does not expire, you can run this command without the need to specify an expiration time.
  • Return values
    • The value increased by num is returned if the operation is successful.
    • Otherwise, an exception is returned.

EXHGETWITHVER

  • Syntax

    EXHGETWITHVER <key> <field>

  • Time complexity

    O(1)

  • Description

    This command is used to retrieve the value and version number of a field in a TairHash that matches a specified key.

  • Parameters and options
    Parameter/option Description
    key The key of the TairHash that you want to manage.
    field An element of the TairHash. A TairHash key can be mapped to multiple fields.
  • Return values
    • The value and version number of the field are returned if the field exists and the operation is successful.
    • nil: the key or field does not exist.
    • Otherwise, an exception is returned.

EXHMGET

  • Syntax

    EXHMGET <key> <field> [field ...]

  • Time complexity

    O(1)

  • Description

    This command is used to retrieve multiple field values in a TairHash that matches a specified key.

  • Parameters and options
    Parameter/option Description
    key The key of the TairHash that you want to manage.
    field An element of the TairHash. A TairHash key can be mapped to multiple fields.
  • Return values
    • nil: the key does not exist.
    • An array is returned if the specified key and fields exist. Each element in the array corresponds to a field value.
    • An array is returned if the specified key exists but some fields do not exist. Each element in the array corresponds to a field value. The elements of the non-existing fields are displayed as nil.
    • Otherwise, an exception is returned.

EXHMGETWITHVER

  • Syntax

    EXHMGETWITHVER <key> <field> [field ...]

  • Time complexity

    O(1)

  • Description

    This command is used to retrieve the values and version numbers of multiple fields in a TairHash that matches a specified key.

  • Parameters and options
    Parameter/option Description
    key The key of the TairHash that you want to manage.
    field An element of the TairHash. A TairHash key can be mapped to multiple fields.
  • Return values
    • nil: the key does not exist.
    • An array is returned if the specified key and fields exist. Each element in the array corresponds to a field value and a version number.
    • An array is returned if the specified key exists but some fields do not exist. Each element in the array corresponds to a field value and a version number. The elements of the fields that do not exist are displayed as nil.
    • Otherwise, an exception is returned.

EXHDEL

  • Syntax

    EXHDEL <key> <field> <field> <field> ...

  • Time complexity

    O(1)

  • Description

    This command is used to delete a field from a TairHash that matches a specified key.

  • Parameters and options
    Parameter/option Description
    key The key of the TairHash that you want to manage.
    field An element of the TairHash. A TairHash key can be mapped to multiple fields.
  • Return values
    • 0: the specified key or field does not exist.
    • 1: the operation is successful.
    • Otherwise, an exception is returned.

EXHLEN

  • Syntax

    EXHLEN <key> [noexp]

  • Time complexity

    O(1)

  • Description

    This command is used to retrieve the number of fields in a TairHash that matches a specified key. The returned value may include the number of expired fields that are not deleted.

  • Parameters and options
    Parameter/option Description
    key The key of the TairHash that you want to manage.
    noexp By default, the EXHLEN command does not delete or filter out expired fields. Therefore, the results may include the number of expired fields that are not deleted. If you want to query only the number of fields that are not expired, you can set the noexp parameter. When you set the noexp parameter,
    • the response time of the EXHLEN command is based on the size of the Tairhash, because the system scans all TairHashes.
    • The result of the EXHLEN command does not include the number of expired fields that are not deleted.
  • Return values
    • 0: the specified key or field does not exist.
    • The number of fields in the TairHash is returned if the operation is successful.
    • Otherwise, an exception is returned.

EXHEXISTS

  • Syntax

    EXHEXISTS <key> <field>

  • Time complexity

    O(1)

  • Description

    This command is used to check whether a field exists in a TairHash that matches a specified key.

  • Parameters and options
    Parameter/option Description
    key The key of the TairHash that you want to manage.
    field An element of the TairHash. A TairHash key can be mapped to multiple fields.
  • Return values
    • 0: the specified key or field does not exist.
    • 1: the specified field exists.
    • Otherwise, an exception is returned.

EXHSTRLEN

  • Syntax

    EXHSTRLEN <key> <field>

  • Time complexity

    O(1)

  • Description

    This command is used to retrieve the length of a field value in a TairHash that matches a specified key.

  • Parameters and options
    Parameter/option Description
    key The key of the TairHash that you want to manage.
    field An element of the TairHash. A TairHash key can be mapped to multiple fields.
  • Return values
    • 0: the specified key or field does not exist.
    • The length of the specified field value is returned if the operation is successful.
    • Otherwise, an exception is returned.

EXHKEYS

  • Syntax

    EXHKEYS <key>

  • Time complexity

    O(1)

  • Description

    This command is used to retrieve all fields in a TairHash that matches a specified key.

  • Parameters and options
    Parameter/option Description
    key The key of the TairHash that you want to manage.
  • Return values
    • If the specified key does not exist, an empty array is returned.
    • If the specified key exists, an array is returned. Each element in the array corresponds to a field.
    • Otherwise, an exception is returned.

EXHVALS

  • Syntax

    EXHVALS <key>

  • Time complexity

    O(1)

  • Description

    This command is used to retrieve all field values in a TairHash that matches a specified key.

  • Parameters and options
    Parameter/option Description
    key The key of the TairHash that you want to manage.
  • Return values
    • If the specified key does not exist, an empty array is returned.
    • If the specified key exists, an array is returned. Each element in the array corresponds to a field value.
    • Otherwise, an exception is returned.

EXHGETALL

  • Syntax

    EXHGETALL <key>

  • Time complexity

    O(1)

  • Description

    This command is used to retrieve all fields and their values in a TairHash that matches a specified key.

  • Parameters and options
    Parameter/option Description
    key The key of the TairHash that you want to manage.
  • Return values
    • If the specified key does not exist, an empty array is returned.
    • If the specified key exists, an array is returned. Each element in the array corresponds to a field-value pair.
    • Otherwise, an exception is returned.

EXHSCAN

  • Syntax

    EXHSCAN <key> <op> <subkey> [MATCH pattern] [COUNT count]

  • Time complexity

    O(1) and O(N)

  • Description

    This command is used to scan TairHashes that match a specified key.

  • Parameters and options
    Parameter/option Description
    key The key of the TairHash that you want to manage.
    op The position from which a scan starts. Valid values:
    • >: specifies that the scan starts from the first field with the value of the key greater than the subkey.
    • >=: specifies that the scan starts from the first field with the value of the key greater than or equal to the subkey.
    • <: specifies that the scan starts from the first field with the value of the key smaller than the subkey.
    • <=: specifies that the scan starts from the first field with the value of the key smaller than or equal to the subkey.
    • ==: specifies that the scan starts from the first field with the value of the key equal to the subkey.
    • ^: specifies that the scan starts from the first field.
    • $: specifies that the scan starts from the last field.
    subkey Specifies the position from which a scan starts. This parameter is set together with the op parameter. If op is set to ^ or $, this parameter does not take effect.
    MATCH The criteria used to filter the scanning result.
  • Return values
    • If the specified key does not exist, an empty array is returned.
    • If the specified key exists, an array is returned. Each element in the array corresponds to a field-value pair.
    • Otherwise, an exception is returned.