@valkey/valkey-glide
    Preparing search index...

    Class ClusterBatch

    Batch implementation for standalone GlideClusterClient. Batches allow the execution of a group of commands in a single step.

    An array of command responses is returned by the client exec command, in the order they were given. Each element in the array represents a command given to the batch. The response for each command depends on the executed Valkey command. Specific response types are documented alongside each method.

    Indicates whether the batch is atomic or non-atomic. If true, the batch will be executed as an atomic transaction. If false, the batch will be executed as a non-atomic pipeline.

    // Example of Atomic Batch (Transaction) in a Cluster
    const transaction = new ClusterBatch(true) // Atomic (Transactional)
    .set("key", "value")
    .get("key");
    const result = await client.exec(transaction, true);
    console.log(result); // ["OK", "value"]
    // Example of Non-Atomic Batch (Pipeline) in a Cluster
    const pipeline = new ClusterBatch(false) // Non-Atomic (Pipeline)
    .set("key1", "value1")
    .set("key2", "value2")
    .get("key1")
    .get("key2");
    const result = await client.exec(pipeline, true);
    console.log(result); // ["OK", "OK", "value1", "value2"]

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    Methods

    addAndReturn append bitcount bitfield bitfieldReadOnly bitop bitpos blmove blmpop blpop brpop bzmpop bzpopmax bzpopmin clientGetName clientId configGet configResetStat configRewrite configSet copy customCommand dbsize decr decrBy del dump echo exists expire expireAt expireTime fcall fcallReadonly flushall flushdb functionDelete functionDump functionFlush functionList functionLoad functionRestore functionStats geoadd geodist geohash geopos geosearch geosearchstore get getbit getdel getex getrange hdel hexists hexpire hexpireat hexpiretime hget hgetall hgetex hincrBy hincrByFloat hkeys hlen hmget hpersist hpexpire hpexpireat hpexpiretime hpttl hrandfield hrandfieldCount hrandfieldWithValues hscan hset hsetex hsetnx hstrlen httl hvals incr incrBy incrByFloat info lastsave lcs lcsIdx lcsLen lindex linsert llen lmove lmpop lolwut lpop lpopCount lpos lpush lpushx lrange lrem lset ltrim mget move mset msetnx objectEncoding objectFreq objectIdletime objectRefcount persist pexpire pexpireAt pexpireTime pfadd pfcount pfmerge ping pttl publish pubsubChannels pubsubNumPat pubsubNumSub pubsubShardChannels pubsubShardNumSub randomKey rename renamenx restore rpop rpopCount rpush rpushx sadd scard sdiff sdiffstore set setbit setrange sinter sintercard sinterstore sismember smembers smismember smove sort sortReadOnly sortStore spop spopCount srandmember srandmemberCount srem sscan strlen sunion sunionstore time touch ttl type unlink wait xack xadd xautoclaim xautoclaimJustId xclaim xclaimJustId xdel xgroupCreate xgroupCreateConsumer xgroupDelConsumer xgroupDestroy xgroupSetId xinfoConsumers xinfoGroups xinfoStream xlen xpending xpendingWithOptions xrange xread xreadgroup xrevrange xtrim zadd zaddIncr zcard zcount zdiff zdiffstore zdiffWithScores zincrby zinter zintercard zinterstore zinterWithScores zlexcount zmpop zmscore zpopmax zpopmin zrandmember zrandmemberWithCount zrandmemberWithCountWithScores zrange zrangeStore zrangeWithScores zrank zrankWithScore zrem zremRangeByLex zremRangeByRank zremRangeByScore zrevrank zrevrankWithScore zscan zscore zunion zunionstore zunionWithScores

    Constructors

    • Parameters

      • isAtomic: boolean

        Determines whether the batch is atomic or non-atomic. If true, the batch will be executed as an atomic transaction. If false, the batch will be executed as a non-atomic pipeline.

      Returns ClusterBatch

    Properties

    commands: Command[] = []
    isAtomic: boolean

    Determines whether the batch is atomic or non-atomic. If true, the batch will be executed as an atomic transaction. If false, the batch will be executed as a non-atomic pipeline.

    setCommandsIndexes: number[] = []

    Array of command indexes indicating commands that need to be converted into a Set within the batch.

    Methods

    • Adds a command to the batch and returns the batch instance.

      Parameters

      • command: Command

        The command to add.

      • shouldConvertToSet: boolean = false

        Indicates if the command should be converted to a Set.

      Returns ClusterBatch

      The updated batch instance.

    • Counts the number of set bits (population counting) in the string stored at key. The options argument can optionally be provided to count the number of bits in a specific string interval.

      Parameters

      • key: GlideString

        The key for the string to count the set bits of.

      • Optionaloptions: BitOffsetOptions

        The offset options - see BitOffsetOptions.

        Command Response - If options is provided, returns the number of set bits in the string interval specified by options. If options is not provided, returns the number of set bits in the string stored at key. Otherwise, if key is missing, returns 0 as it is treated as an empty string.

      Returns ClusterBatch

    • Returns the position of the first bit matching the given bit value. The optional starting offset start is a zero-based index, with 0 being the first byte of the list, 1 being the next byte and so on. The offset can also be a negative number indicating an offset starting at the end of the list, with -1 being the last byte of the list, -2 being the penultimate, and so on.

      Parameters

      • key: GlideString

        The key of the string.

      • bit: number

        The bit value to match. Must be 0 or 1.

      • Optionaloptions: BitOffsetOptions

        (Optional) The BitOffsetOptions.

        Command Response - The position of the first occurrence of bit in the binary value of the string held at key. If start was provided, the search begins at the offset indicated by start.

      Returns ClusterBatch

    • Blocks the connection until it pops atomically and removes the left/right-most element to the list stored at source depending on whereFrom, and pushes the element at the first/last element of the list stored at destination depending on whereTo. BLMOVE is the blocking variant of lmove.

      Parameters

      • source: GlideString

        The key to the source list.

      • destination: GlideString

        The key to the destination list.

      • whereFrom: ListDirection

        The ListDirection to remove the element from.

      • whereTo: ListDirection

        The ListDirection to add the element to.

      • timeout: number

        The number of seconds to wait for a blocking operation to complete. A value of 0 will block indefinitely.

        Command Response - The popped element, or null if source does not exist or if the operation timed-out.

      Returns ClusterBatch

      When in cluster mode, both source and destination must map to the same hash slot.

    • Blocks the connection until it pops one or more elements from the first non-empty list from the provided key. BLMPOP is the blocking variant of lmpop.

      Parameters

      • keys: GlideString[]

        An array of keys to lists.

      • direction: ListDirection

        The direction based on which elements are popped from - see ListDirection.

      • timeout: number

        The number of seconds to wait for a blocking operation to complete. A value of 0 will block indefinitely.

      • Optionalcount: number

        (Optional) The maximum number of popped elements.

        Command Response - A Record which stores the key name where elements were popped out and the array of popped elements. If no member could be popped and the timeout expired, returns null.

      Returns ClusterBatch

      Since Valkey version 7.0.0.

    • Blocking list pop primitive. Pop an element from the head of the first list that is non-empty, with the given keys being checked in the order that they are given. Blocks the connection when there are no elements to pop from any of the given lists.

      Parameters

      • keys: GlideString[]

        The keys of the lists to pop from.

      • timeout: number

        The timeout in seconds.

        Command Response - An array containing the key from which the element was popped and the value of the popped element, formatted as [key, value]. If no element could be popped and the timeout expired, returns null.

      Returns ClusterBatch

      BLPOP is a blocking command, see Blocking Commands for more details and best practices.

    • Blocking list pop primitive. Pop an element from the tail of the first list that is non-empty, with the given keys being checked in the order that they are given. Blocks the connection when there are no elements to pop from any of the given lists.

      Parameters

      • keys: GlideString[]

        The keys of the lists to pop from.

      • timeout: number

        The timeout in seconds.

        Command Response - An array containing the key from which the element was popped and the value of the popped element, formatted as [key, value]. If no element could be popped and the timeout expired, returns null.

      Returns ClusterBatch

      BRPOP is a blocking command, see Blocking Commands for more details and best practices.

    • Pops a member-score pair from the first non-empty sorted set, with the given keys being checked in the order they are provided. Blocks the connection when there are no members to pop from any of the given sorted sets. BZMPOP is the blocking variant of zmpop.

      Parameters

      • keys: GlideString[]

        The keys of the sorted sets.

      • modifier: ScoreFilter

        The element pop criteria - either ScoreFilter.MIN or ScoreFilter.MAX to pop the member with the lowest/highest score accordingly.

      • timeout: number

        The number of seconds to wait for a blocking operation to complete. A value of 0 will block indefinitely.

      • Optionalcount: number

        (Optional) The number of elements to pop. If not supplied, only one element will be popped.

        Command Response - A two-element array containing the key name of the set from which the element was popped, and a GlideRecord<number> of the popped elements - see GlideRecord. If no member could be popped, returns null.

      Returns ClusterBatch

      BZMPOP is a client blocking command, see Valkey Glide Wiki for more details and best practices.

    • Blocks the connection until it removes and returns a member with the highest score from the first non-empty sorted set, with the given key being checked in the order they are provided. BZPOPMAX is the blocking variant of zpopmax.

      Parameters

      • keys: GlideString[]

        The keys of the sorted sets.

      • timeout: number

        The number of seconds to wait for a blocking operation to complete. A value of 0 will block indefinitely. Since 6.0.0: timeout is interpreted as a double instead of an integer.

        Command Response - An array containing the key where the member was popped out, the member, itself, and the member score. If no member could be popped and the timeout expired, returns null.

      Returns ClusterBatch

    • Blocks the connection until it removes and returns a member with the lowest score from the first non-empty sorted set, with the given key being checked in the order they are provided. BZPOPMIN is the blocking variant of zpopmin.

      Parameters

      • keys: GlideString[]

        The keys of the sorted sets.

      • timeout: number

        The number of seconds to wait for a blocking operation to complete. A value of 0 will block indefinitely. Since Valkey version 6.0.0: timeout is interpreted as a double instead of an integer.

        Command Response - An array containing the key where the member was popped out, the member, itself, and the member score. If no member could be popped and the timeout expired, returns null.

      Returns ClusterBatch

    • Reads the configuration parameters of the running server. Starting from server version 7, command supports multiple parameters.

      Parameters

      • parameters: string[]

        A list of configuration parameter names to retrieve values for.

        Command Response - A map of values corresponding to the configuration parameters.

      Returns ClusterBatch

    • Copies the value stored at the source to the destination key. If destinationDB is specified, the value will be copied to the database specified, otherwise the current database will be used. When replace is true, removes the destination key first if it already exists, otherwise performs no action.

      Parameters

      • source: GlideString

        The key to the source value.

      • destination: GlideString

        The key where the value should be copied to.

      • Optionaloptions: { destinationDB?: number; replace?: boolean }

      Returns ClusterBatch

      Since Valkey version 6.2.0. destinationDB parameter for cluster mode is supported since Valkey 9.0.0 and above

    • Executes a single command, without checking inputs. Every part of the command, including subcommands, should be added as a separate value in args.

      Parameters

      Returns ClusterBatch

      Glide Wiki for details on the restrictions and limitations of the custom command API.

      Command Response - A response from Valkey with an Object.

    • Serialize the value stored at key in a Valkey-specific format and return it to the user.

      Parameters

      • key: GlideString

        The key to serialize.

        Command Response - The serialized value of the data stored at key. If key does not exist, null will be returned.

      Returns ClusterBatch

      To execute a batch with a dump command, the exec command requires Decoder.Bytes to handle the response.

    • Sets a timeout on key in seconds. After the timeout has expired, the key will automatically be deleted. If key already has an existing expire set, the time to live is updated to the new value. If seconds is non-positive number, the key will be deleted rather than expired. The timeout will only be cleared by commands that delete or overwrite the contents of key.

      Parameters

      • key: GlideString

        The key to set timeout on it.

      • seconds: number

        The timeout in seconds.

      • Optionaloptions: { expireOption?: ExpireOptions }

        (Optional) Additional parameters:

        • (Optional) expireOption: the expire option - see ExpireOptions.

        Command Response - true if the timeout was set. false if the timeout was not set. e.g. key doesn't exist, or operation skipped due to the provided arguments.

      Returns ClusterBatch

    • Sets a timeout on key. It takes an absolute Unix timestamp (seconds since January 1, 1970) instead of specifying the number of seconds. A timestamp in the past will delete the key immediately. After the timeout has expired, the key will automatically be deleted. If key already has an existing expire set, the time to live is updated to the new value. The timeout will only be cleared by commands that delete or overwrite the contents of key.

      Parameters

      • key: GlideString

        The key to set timeout on it.

      • unixSeconds: number

        The timeout in an absolute Unix timestamp.

      • Optionaloptions: { expireOption?: ExpireOptions }

        (Optional) Additional parameters:

        • (Optional) expireOption: the expire option - see ExpireOptions.

        Command Response - true if the timeout was set. false if the timeout was not set. e.g. key doesn't exist, or operation skipped due to the provided arguments.

      Returns ClusterBatch

    • Returns the absolute Unix timestamp (since January 1, 1970) at which the given key will expire, in seconds. To get the expiration with millisecond precision, use pexpiretime.

      Parameters

      • key: GlideString

        The key to determine the expiration value of.

        Command Response - The expiration Unix timestamp in seconds, -2 if key does not exist or -1 if key exists but has no associated expire.

      Returns ClusterBatch

      Since Valkey version 7.0.0.

    • Returns the positions (longitude, latitude) of all the specified members of the geospatial index represented by the sorted set at key.

      Parameters

      • key: GlideString

        The key of the sorted set.

      • members: GlideString[]

        The members for which to get the positions.

        Command Response - A 2D Array which represents positions (longitude and latitude) corresponding to the given members. The order of the returned positions matches the order of the input members. If a member does not exist, its position will be null.

      Returns ClusterBatch

    • Returns the members of a sorted set populated with geospatial information using geoadd, which are within the borders of the area specified by a given shape.

      Parameters

      • key: GlideString

        The key of the sorted set.

      • searchFrom: SearchOrigin

        The query's center point options, could be one of:

        • MemberOrigin to use the position of the given existing member in the sorted set.

        • CoordOrigin to use the given longitude and latitude coordinates.

      • searchBy: GeoSearchShape

        The query's shape options, could be one of:

        • GeoCircleShape to search inside circular area according to given radius.

        • GeoBoxShape to search inside an axis-aligned rectangle, determined by height and width.

      • OptionalresultOptions: GeoSearchResultOptions

        The optional inputs to request additional information and configure sorting/limiting the results, see GeoSearchResultOptions.

        Command Response - By default, returns an Array of members (locations) names. If any of withCoord, withDist or withHash are set to true in GeoSearchResultOptions, a 2D Array returned, where each sub-array represents a single item in the following order:

        • The member (location) name.
        • The distance from the center as a floating point number, in the same unit specified for searchBy.
        • The geohash of the location as a integer number.
        • The coordinates as a two item array of floating point numbers.

      Returns ClusterBatch

      Since Valkey version 6.2.0.

    • Get the value of key and optionally set its expiration. GETEX is similar to get.

      Parameters

      • key: GlideString

        The key to retrieve from the database.

      • Optionaloptions: { duration: number; type: TimeUnit } | "persist"

        (Optional) set expiriation to the given key. "persist" will retain the time to live associated with the key. Equivalent to PERSIST in the VALKEY API. Otherwise, a TimeUnit and duration of the expire time should be specified.

        Command Response - If key exists, returns the value of key as a string. Otherwise, return null.

      Returns ClusterBatch

      Since Valkey version 6.2.0.

    • Returns the substring of the string value stored at key, determined by the byte offsets start and end (both are inclusive). Negative offsets can be used in order to provide an offset starting from the end of the string. So -1 means the last character, -2 the penultimate and so forth. If key does not exist, an empty string is returned. If start or end are out of range, returns the substring within the valid range of the string.

      Parameters

      • key: GlideString

        The key of the string.

      • start: number

        The starting byte offset.

      • end: number

        The ending byte offset.

        Command Response - substring extracted from the value stored at key.

      Returns ClusterBatch

    • Sets expiration time for hash fields in seconds. Creates the hash if it doesn't exist.

      Parameters

      • key: GlideString

        The key of the hash.

      • seconds: number

        The expiration time in seconds.

      • fields: GlideString[]

        The fields to set expiration for.

      • Optionaloptions: HExpireOptions

        Optional arguments for the HEXPIRE command. See HExpireOptions.

        Command Response - An array of numbers indicating the result for each field: - 1 if expiration was set successfully - 0 if the specified condition (NX, XX, GT, LT) was not met - -2 if the field does not exist or the key does not exist - 2 when called with 0 seconds (field deleted)

      Returns ClusterBatch

    • Sets expiration time for hash fields using an absolute Unix timestamp in seconds. Creates the hash if it doesn't exist.

      Parameters

      • key: GlideString

        The key of the hash.

      • unixTimestampSeconds: number

        The expiration time as a Unix timestamp in seconds.

      • fields: GlideString[]

        The fields to set expiration for.

      • Optionaloptions: HExpireOptions

        Optional arguments for the HEXPIREAT command. See HExpireOptions.

        Command Response - An array of numbers indicating the result for each field: - 1 if expiration was set successfully - 0 if the specified condition (NX, XX, GT, LT) was not met - -2 if the field does not exist or the key does not exist - 2 when called with 0 seconds (field deleted)

      Returns ClusterBatch

    • Gets hash fields and optionally sets their expiration.

      Parameters

      Returns ClusterBatch

      // Get fields without setting expiration
      batch.hgetex("myHash", ["field1", "field2"]);

      // Get fields and set 30 second expiration
      batch.hgetex(
      "myHash",
      ["field1", "field2"],
      { expiry: { type: TimeUnit.Seconds, count: 30 } }
      );

      // Get fields and remove expiration (make persistent)
      batch.hgetex(
      "myHash",
      ["field1", "field2"],
      { expiry: "PERSIST" }
      );

      // Get fields and set millisecond precision expiration
      batch.hgetex(
      "myHash",
      ["field3"],
      { expiry: { type: TimeUnit.Milliseconds, count: 5000 } }
      );

      Command Response - An array of values associated with the given fields, in the same order as they are requested. For every field that does not exist in the hash, a null value is returned. If key does not exist, returns an array of null values.

      Valkey 9.0.0

    • Increments the number stored at field in the hash stored at key by increment. By using a negative increment value, the value stored at field in the hash stored at key is decremented. If field or key does not exist, it is set to 0 before performing the operation.

      Parameters

      • key: GlideString

        The key of the hash.

      • field: GlideString

        The field in the hash stored at key to increment its value.

        Command Response - the value of field in the hash stored at key after the increment.

      • amount: number

        The amount to increment.

      Returns ClusterBatch

    • Increment the string representing a floating point number stored at field in the hash stored at key by increment. By using a negative increment value, the value stored at field in the hash stored at key is decremented. If field or key does not exist, it is set to 0 before performing the operation.

      Parameters

      • key: GlideString

        The key of the hash.

      • field: GlideString

        The field in the hash stored at key to increment its value.

        Command Response - the value of field in the hash stored at key after the increment.

      • amount: number

        The amount to increment.

      Returns ClusterBatch

    • Returns the values associated with the specified fields in the hash stored at key.

      Parameters

      • key: GlideString

        The key of the hash.

      • fields: GlideString[]

        The fields in the hash stored at key to retrieve from the database.

        Command Response - a list of values associated with the given fields, in the same order as they are requested. For every field that does not exist in the hash, a null value is returned. If key does not exist, it is treated as an empty hash and it returns a list of null values.

      Returns ClusterBatch

    • Retrieves up to count random field names from the hash value stored at key.

      Parameters

      • key: GlideString

        The key of the hash.

      • count: number

        The number of field names to return. If count is positive, returns unique elements. If negative, allows for duplicates.

        Command Response - An array of random field names from the hash stored at key, or an empty array when the key does not exist.

      Returns ClusterBatch

      Since Valkey version 6.2.0.

    • Retrieves up to count random field names along with their values from the hash value stored at key.

      Parameters

      • key: GlideString

        The key of the hash.

      • count: number

        The number of field names to return. If count is positive, returns unique elements. If negative, allows for duplicates.

        Command Response - A 2D array of [fieldName, value] arrays, where fieldName is a random field name from the hash and value is the associated value of the field name. If the hash does not exist or is empty, the response will be an empty array.

      Returns ClusterBatch

      Since Valkey version 6.2.0.

    • Iterates incrementally over a hash.

      Parameters

      • key: GlideString

        The key of the set.

      • cursor: string

        The cursor that points to the next iteration of results. A value of "0" indicates the start of the search.

      • Optionaloptions: HScanOptions

        (Optional) The HScanOptions.

        Command Response - An array of the cursor and the subset of the hash held by key. The first element is always the cursor for the next iteration of results. "0" will be the cursor returned on the last iteration of the hash. The second element is always an array of the subset of the hash held in key. The array in the second element is a flattened series of string pairs, where the value is at even indices and the value is at odd indices. If options.noValues is set to true, the second element will only contain the fields without the values.

      Returns ClusterBatch

    • Sets hash fields with expiration times and optional conditional changes.

      Parameters

      Returns ClusterBatch

      // Set fields with 60 second expiration, only if none exist
      batch.hsetex(
      "myHash",
      { field1: "value1", field2: "value2" },
      {
      fieldConditionalChange: HashFieldConditionalChange.ONLY_IF_NONE_EXIST,
      expiry: { type: TimeUnit.Seconds, count: 60 }
      }
      );

      // Set fields and keep existing TTL
      batch.hsetex(
      "myHash",
      { field3: "value3" },
      { expiry: "KEEPTTL" }
      );

      // Set fields with Unix timestamp expiration
      batch.hsetex(
      "myHash",
      { field4: "value4" },
      { expiry: { type: TimeUnit.UnixSeconds, count: Math.floor(Date.now() / 1000) + 3600 } }
      );

      Command Response - The number of fields that were added to the hash.

      Valkey 9.0.0

    • Returns the remaining time to live of hash fields that have a timeout, in seconds.

      Parameters

      • key: GlideString

        The key of the hash.

      • fields: GlideString[]

        The fields in the hash stored at key to retrieve the TTL for.

        Command Response - An array of TTL values in seconds for the specified fields. - For fields with a timeout, returns the remaining time in seconds. - For fields that exist but have no associated expire, returns -1. - For fields that do not exist, returns -2.

      Returns ClusterBatch

    • Increment the string representing a floating point number stored at key by amount. By using a negative amount value, the result is that the value stored at key is decremented. If key does not exist, it is set to 0 before performing the operation.

      Parameters

      • key: GlideString

        The key to increment its value.

      • amount: number

        The amount to increment.

        Command Response - the value of key after the increment.

      Returns ClusterBatch

    • Returns the indices and lengths of the longest common subsequences between strings stored at key1 and key2.

      Parameters

      • key1: GlideString

        The key that stores the first string.

      • key2: GlideString

        The key that stores the second string.

      • Optionaloptions: { minMatchLen?: number; withMatchLen?: boolean }

        (Optional) Additional parameters:

        • (Optional) withMatchLen: if true, include the length of the substring matched for the each match.
        • (Optional) minMatchLen: the minimum length of matches to include in the result.

        Command Response - A GlideRecord containing the indices of the longest common subsequences between the 2 strings and the lengths of the longest common subsequences. The resulting map contains two keys, "matches" and "len": - "len" is mapped to the total length of the all longest common subsequences between the 2 strings stored as an integer. This value doesn't count towards the minMatchLen filter. - "matches" is mapped to a three dimensional array of integers that stores pairs of indices that represent the location of the common subsequences in the strings held by key1 and key2.

        See example of BaseClient.lcsIdx|lcsIdx for more details.
        

      Returns ClusterBatch

      Since Valkey version 7.0.0.

    • Returns the element at index index in the list stored at key. The index is zero-based, so 0 means the first element, 1 the second element and so on. Negative indices can be used to designate elements starting at the tail of the list. Here, -1 means the last element, -2 means the penultimate and so forth.

      Parameters

      • key: GlideString

        The key of the list.

      • index: number

        The index of the element in the list to retrieve. Command Response - The element at index in the list stored at key. If index is out of range or if key does not exist, null is returned.

      Returns ClusterBatch

    • Pops one or more elements from the first non-empty list from the provided keys.

      Parameters

      • keys: GlideString[]

        An array of keys to lists.

      • direction: ListDirection

        The direction based on which elements are popped from - see ListDirection.

      • Optionalcount: number

        (Optional) The maximum number of popped elements.

        Command Response - A Record which stores the key name where elements were popped out and the array of popped elements. If no member could be popped, returns null.

      Returns ClusterBatch

      Since Valkey version 7.0.0.

    • Returns the index of the first occurrence of element inside the list specified by key. If no match is found, null is returned. If the count option is specified, then the function returns an array of indices of matching elements within the list.

      Parameters

      • key: GlideString

        The name of the list.

      • element: GlideString

        The value to search for within the list.

      • Optionaloptions: LPosOptions

        (Optional) The LPOS options - see LPosOptions.

        Command Response - The index of element, or null if element is not in the list. If the count option is specified, then the function returns an array of indices of matching elements within the list.

      Returns ClusterBatch

      Since Valkey version 6.0.6.

    • Inserts all the specified values at the head of the list stored at key. elements are inserted one after the other to the head of the list, from the leftmost element to the rightmost element. If key does not exist, it is created as empty list before performing the push operations.

      Parameters

      • key: GlideString

        The key of the list.

      • elements: GlideString[]

        The elements to insert at the head of the list stored at key.

        Command Response - the length of the list after the push operations.

      Returns ClusterBatch

    • Returns the specified elements of the list stored at key. The offsets start and end are zero-based indexes, with 0 being the first element of the list, 1 being the next element and so on. These offsets can also be negative numbers indicating offsets starting at the end of the list, with -1 being the last element of the list, -2 being the penultimate, and so on.

      Parameters

      • key: GlideString

        The key of the list.

      • start: number

        The starting point of the range.

      • end: number

        The end of the range.

        Command Response - list of elements in the specified range. If start exceeds the end of the list, or if start is greater than end, an empty list will be returned. If end exceeds the actual end of the list, the range will stop at the actual end of the list. If key does not exist an empty list will be returned.

      Returns ClusterBatch

    • Removes the first count occurrences of elements equal to element from the list stored at key.

      Parameters

      • key: GlideString

        The key of the list.

      • count: number

        The count of the occurrences of elements equal to element to remove. If count is positive : Removes elements equal to element moving from head to tail. If count is negative : Removes elements equal to element moving from tail to head. If count is 0 or count is greater than the occurrences of elements equal to element: Removes all elements equal to element.

      • element: GlideString

        The element to remove from the list.

        Command Response - the number of the removed elements. If key does not exist, 0 is returned.

      Returns ClusterBatch

    • Sets the list element at index to element. The index is zero-based, so 0 means the first element, 1 the second element and so on. Negative indices can be used to designate elements starting at the tail of the list. Here, -1 means the last element, -2 means the penultimate and so forth.

      Parameters

      • key: GlideString

        The key of the list.

      • index: number

        The index of the element in the list to be set.

      • element: GlideString

        The new element to set at the specified index.

        Command Response - Always "OK".

      Returns ClusterBatch

    • Trim an existing list so that it will contain only the specified range of elements specified. The offsets start and end are zero-based indexes, with 0 being the first element of the list, 1 being the next element and so on. These offsets can also be negative numbers indicating offsets starting at the end of the list, with -1 being the last element of the list, -2 being the penultimate, and so on.

      Parameters

      • key: GlideString

        The key of the list.

      • start: number

        The starting point of the range.

      • end: number

        The end of the range.

        Command Response - always "OK". If start exceeds the end of the list, or if start is greater than end, the list is emptied and the key is removed. If end exceeds the actual end of the list, it will be treated like the last element of the list. If key does not exist the command will be ignored.

      Returns ClusterBatch

    • Move key from the currently selected database to the database specified by dbIndex.

      Parameters

      • key: GlideString

        The key to move.

      • dbIndex: number

        The index of the database to move key to.

        Command Response - true if key was moved, or false if the key already exists in the destination database or does not exist in the source database.

      Returns ClusterBatch

      Move is available for cluster mode since Valkey 9.0.0 and above.

    • Sets a timeout on key in milliseconds. After the timeout has expired, the key will automatically be deleted. If key already has an existing expire set, the time to live is updated to the new value. If milliseconds is non-positive number, the key will be deleted rather than expired. The timeout will only be cleared by commands that delete or overwrite the contents of key.

      Parameters

      • key: GlideString

        The key to set timeout on it.

      • milliseconds: number

        The timeout in milliseconds.

      • Optionaloptions: { expireOption?: ExpireOptions }

        (Optional) Additional parameters:

        • (Optional) expireOption: the expire option - see ExpireOptions.

        Command Response - true if the timeout was set. false if the timeout was not set. e.g. key doesn't exist, or operation skipped due to the provided arguments.

      Returns ClusterBatch

    • Sets a timeout on key. It takes an absolute Unix timestamp (milliseconds since January 1, 1970) instead of specifying the number of milliseconds. A timestamp in the past will delete the key immediately. After the timeout has expired, the key will automatically be deleted. If key already has an existing expire set, the time to live is updated to the new value. The timeout will only be cleared by commands that delete or overwrite the contents of key.

      Parameters

      • key: GlideString

        The key to set timeout on it.

      • unixMilliseconds: number

        The timeout in an absolute Unix timestamp.

      • Optionaloptions: { expireOption?: ExpireOptions }

        (Optional) Additional parameters:

        • (Optional) expireOption: the expire option - see ExpireOptions.

        Command Response - true if the timeout was set. false if the timeout was not set. e.g. key doesn't exist, or operation skipped due to the provided arguments.

      Returns ClusterBatch

    • Adds all elements to the HyperLogLog data structure stored at the specified key. Creates a new structure if the key does not exist. When no elements are provided, and key exists and is a HyperLogLog, then no operation is performed.

      Parameters

      • key: GlideString

        The key of the HyperLogLog data structure to add elements into.

      • elements: GlideString[]

        An array of members to add to the HyperLogLog stored at key. Command Response - If the HyperLogLog is newly created, or if the HyperLogLog approximated cardinality is altered, then returns true. Otherwise, returns false.

      Returns ClusterBatch

    • Estimates the cardinality of the data stored in a HyperLogLog structure for a single key or calculates the combined cardinality of multiple keys by merging their HyperLogLogs temporarily.

      Parameters

      • keys: GlideString[]

        The keys of the HyperLogLog data structures to be analyzed. Command Response - The approximated cardinality of given HyperLogLog data structures. The cardinality of a key that does not exist is 0.

      Returns ClusterBatch

    • Publish a message on pubsub channel. This command aggregates PUBLISH and SPUBLISH commands functionalities. The mode is selected using the 'sharded' parameter. For both sharded and non-sharded mode, request is routed using hashed channel as key.

      Parameters

      • message: GlideString

        Message to publish.

      • channel: GlideString

        Channel to publish the message on.

      • sharded: boolean = false

        Use sharded pubsub mode. Available since Valkey version 7.0.

        Command Response - Number of subscriptions in primary node that received the message.

      Returns ClusterBatch

    • Returns the number of unique patterns that are subscribed to by clients.

      Note: This is the total number of unique patterns all the clients are subscribed to, not the count of clients subscribed to patterns. The command is routed to all nodes, and aggregates the response to the sum of all pattern subscriptions.

      Returns ClusterBatch

      https://valkey.io/commands/pubsub-numpat/|valkey.io for more details.

      Command Response - The number of unique patterns.

    • Lists the currently active shard channels. The command is routed to all nodes, and aggregates the response to a single array.

      Parameters

      • Optionalpattern: GlideString

        A glob-style pattern to match active shard channels. If not provided, all active shard channels are returned.

        Command Response - A list of currently active shard channels matching the given pattern. If no pattern is specified, all active shard channels are returned.

      Returns ClusterBatch

    • Returns the number of subscribers (exclusive of clients subscribed to patterns) for the specified shard channels.

      Parameters

      • channels: GlideString[]

        The list of shard channels to query for the number of subscribers.

        Command Response - A list of the shard channel names and their numbers of subscribers.

      Returns ClusterBatch

      The command is routed to all nodes, and aggregates the response into a single list.

    • Create a key associated with a value that is obtained by deserializing the provided serialized value (obtained via dump).

      Parameters

      • key: GlideString

        The key to create.

      • ttl: number

        The expiry time (in milliseconds). If 0, the key will persist.

      • value: Buffer

        The serialized value to deserialize and assign to key.

      • Optionaloptions: RestoreOptions

        (Optional) Restore options RestoreOptions.

        Command Response - Return "OK" if the key was successfully restored with a value.

      Returns ClusterBatch

      options.idletime and options.frequency modifiers cannot be set at the same time.

    • Inserts all the specified values at the tail of the list stored at key. elements are inserted one after the other to the tail of the list, from the leftmost element to the rightmost element. If key does not exist, it is created as empty list before performing the push operations.

      Parameters

      • key: GlideString

        The key of the list.

      • elements: GlideString[]

        The elements to insert at the tail of the list stored at key.

        Command Response - the length of the list after the push operations.

      Returns ClusterBatch

    • Adds the specified members to the set stored at key. Specified members that are already a member of this set are ignored. If key does not exist, a new set is created before adding members.

      Parameters

      • key: GlideString

        The key to store the members to its set.

      • members: GlideString[]

        A list of members to add to the set stored at key.

        Command Response - the number of members that were added to the set, not including all the members already present in the set.

      Returns ClusterBatch

    • Sets or clears the bit at offset in the string value stored at key. The offset is a zero-based index, with 0 being the first element of the list, 1 being the next element, and so on. The offset must be less than 2^32 and greater than or equal to 0. If a key is non-existent then the bit at offset is set to value and the preceding bits are set to 0.

      Parameters

      • key: GlideString

        The key of the string.

      • offset: number

        The index of the bit to be set.

      • value: number

        The bit value to set at offset. The value must be 0 or 1.

        Command Response - The bit value that was previously stored at offset.

      Returns ClusterBatch

    • Overwrites part of the string stored at key, starting at the specified byte offset, for the entire length of value. If the offset is larger than the current length of the string at key, the string is padded with zero bytes to make offset fit. Creates the key if it doesn't exist.

      Parameters

      • key: GlideString

        The key of the string to update.

      • offset: number

        The byte position in the string where value should be written.

      • value: GlideString

        The string written with offset.

        Command Response - The length of the string stored at key after it was modified.

      Returns ClusterBatch

    • Gets the cardinality of the intersection of all the given sets.

      Parameters

      • keys: GlideString[]

        The keys of the sets.

      • Optionaloptions: { limit?: number }

        (Optional) Additional parameters:

        • (Optional) limit: the limit for the intersection cardinality value. If not specified, or set to 0, no limit is used.

        Command Response - The cardinality of the intersection result. If one or more sets do not exist, 0 is returned.

      Returns ClusterBatch

      Since Valkey version 7.0.0.

    • Sorts the elements in the list, set, or sorted set at key and returns the result.

      The sortReadOnly command can be used to sort elements based on different criteria and apply transformations on sorted elements.

      This command is routed depending on the client's ReadFrom strategy.

      Parameters

      • key: GlideString

        The key of the list, set, or sorted set to be sorted.

      • Optionaloptions: SortOptions

        (Optional) SortOptions.

        Command Response - An Array of sorted elements

      Returns ClusterBatch

      Since Valkey version 7.0.0.

    • Removes and returns up to count random members from the set value store at key, depending on the set's length.

      Parameters

      • key: GlideString

        The key of the set.

      • count: number

        The count of the elements to pop from the set.

        Command Response - A list of popped elements will be returned depending on the set's length. If key does not exist, empty list will be returned.

      Returns ClusterBatch

    • Removes the specified members from the set stored at key. Specified members that are not a member of this set are ignored.

      Parameters

      • key: GlideString

        The key to remove the members from its set.

      • members: GlideString[]

        A list of members to remove from the set stored at key.

        Command Response - the number of members that were removed from the set, not including non existing members. If key does not exist, it is treated as an empty set and this command returns 0.

      Returns ClusterBatch

    • Blocks the current client until all the previous write commands are successfully transferred and acknowledged by at least numreplicas of replicas. If timeout is reached, the command returns the number of replicas that were not yet reached.

      Parameters

      • numreplicas: number

        The number of replicas to reach.

      • timeout: number

        The timeout value specified in milliseconds. A value of 0 will block indefinitely.

        Command Response - The number of replicas reached by all the writes performed in the context of the current connection.

      Returns ClusterBatch

    • Transfers ownership of pending stream entries that match the specified criteria.

      Parameters

      • key: GlideString

        The key of the stream.

      • group: GlideString

        The consumer group name.

      • consumer: GlideString

        The group consumer.

      • minIdleTime: number

        The minimum idle time for the message to be claimed.

      • start: string

        Filters the claimed entries to those that have an ID equal or greater than the specified value.

      • Optionaloptions: { count?: number }

        (Optional) Additional parameters:

        • (Optional) count: the number of claimed entries. Default value is 100.

        Command Response - An array containing the following elements:

        • A stream ID to be used as the start argument for the next call to XAUTOCLAIM. This ID is equivalent to the next ID in the stream after the entries that were scanned, or "0-0" if the entire stream was scanned.

        • A mapping of the claimed entries.

        • If you are using Valkey 7.0.0 or above, the response list will also include a list containing the message IDs that were in the Pending Entries List but no longer exist in the stream. These IDs are deleted from the Pending Entries List.

          The response comes in format [GlideString, GlideRecord<[GlideString, GlideString][]>, GlideString[]?], see GlideRecord.

      Returns ClusterBatch

      Since Valkey version 6.2.0.

    • Transfers ownership of pending stream entries that match the specified criteria.

      Parameters

      • key: GlideString

        The key of the stream.

      • group: GlideString

        The consumer group name.

      • consumer: GlideString

        The group consumer.

      • minIdleTime: number

        The minimum idle time for the message to be claimed.

      • start: string

        Filters the claimed entries to those that have an ID equal or greater than the specified value.

      • Optionaloptions: { count?: number }

        (Optional) Additional parameters:

        • (Optional) count: limits the number of claimed entries to the specified value. Default value is 100.

        Command Response - An array containing the following elements:

        • A stream ID to be used as the start argument for the next call to XAUTOCLAIM. This ID is equivalent to the next ID in the stream after the entries that were scanned, or "0-0" if the entire stream was scanned.
        • A list of the IDs for the claimed entries.
        • If you are using Valkey 7.0.0 or above, the response list will also include a list containing the message IDs that were in the Pending Entries List but no longer exist in the stream. These IDs are deleted from the Pending Entries List.

      Returns ClusterBatch

      Since Valkey version 6.2.0.

    • Removes the specified entries by id from a stream, and returns the number of entries deleted.

      Parameters

      • key: GlideString

        The key of the stream.

      • ids: string[]

        An array of entry ids.

        Command Response - The number of entries removed from the stream. This number may be less than the number of entries in ids, if the specified ids don't exist in the stream.

      Returns ClusterBatch

    • Sets the last delivered ID for a consumer group.

      Parameters

      • key: GlideString

        The key of the stream.

      • groupName: GlideString

        The consumer group name.

      • id: string

        The stream entry ID that should be set as the last delivered ID for the consumer group.

      • Optionaloptions: { entriesRead?: number }

        (Optional) Additional parameters:

        • (Optional) entriesRead: the number of stream entries already read by the group. This option can only be specified if you are using Valkey version 7.0.0 or above.

        Command Response - "OK".

      Returns ClusterBatch

    • Returns information about the stream stored at key.

      Parameters

      • key: GlideString

        The key of the stream.

      • OptionalfullOptions: number | boolean

        If true, returns verbose information with a limit of the first 10 PEL entries. If number is specified, returns verbose information limiting the returned PEL entries. If 0 is specified, returns verbose information with no limit.

        Command Response - Detailed stream information for the given key. See example of BaseClient.xinfoStream for more details. The response comes in format GlideRecord<StreamEntries | GlideRecord<StreamEntries | GlideRecord<StreamEntries>[]>[]>, see GlideRecord.

      Returns ClusterBatch

    • Returns stream entries matching a given range of entry IDs.

      Parameters

      • key: GlideString

        The key of the stream.

      • start: Boundary<string>

        The starting stream entry ID bound for the range. - Use value to specify a stream entry ID. - Use isInclusive: false to specify an exclusive bounded stream entry ID. This is only available starting with Valkey version 6.2.0. - Use InfBoundary.NegativeInfinity to start with the minimum available ID.

      • end: Boundary<string>

        The ending stream ID bound for the range. - Use value to specify a stream entry ID. - Use isInclusive: false to specify an exclusive bounded stream entry ID. This is only available starting with Valkey version 6.2.0. - Use InfBoundary.PositiveInfinity to end with the maximum available ID.

      • Optionalcount: number

        An optional argument specifying the maximum count of stream entries to return. If count is not provided, all stream entries in the range will be returned.

        Command Response - A list of stream entry ids, to an array of entries, or null if count is non-positive. The response comes in format GlideRecord<[GlideString, GlideString][]> | null, see GlideRecord.

      Returns ClusterBatch

    • Returns stream entries matching a given range of entry IDs in reverse order. Equivalent to xrange but returns the entries in reverse order.

      Parameters

      • key: GlideString

        The key of the stream.

      • end: Boundary<string>

        The ending stream entry ID bound for the range. - Use value to specify a stream entry ID. - Use isInclusive: false to specify an exclusive bounded stream entry ID. This is only available starting with Valkey version 6.2.0. - Use InfBoundary.PositiveInfinity to end with the maximum available ID.

      • start: Boundary<string>

        The ending stream ID bound for the range. - Use value to specify a stream entry ID. - Use isInclusive: false to specify an exclusive bounded stream entry ID. This is only available starting with Valkey version 6.2.0. - Use InfBoundary.NegativeInfinity to start with the minimum available ID.

      • Optionalcount: number

        An optional argument specifying the maximum count of stream entries to return. If count is not provided, all stream entries in the range will be returned.

        Command Response - A list of stream entry ids, to an array of entries, or null if count is non-positive. The response comes in format GlideRecord<[GlideString, GlideString][]> | null, see GlideRecord.

      Returns ClusterBatch

    • Increments the score of member in the sorted set stored at key by increment. If member does not exist in the sorted set, it is added with increment as its score (as if its previous score was 0.0). If key does not exist, a new sorted set with the specified member as its sole member is created.

      Parameters

      • key: GlideString

        The key of the sorted set.

      • member: GlideString

        A member in the sorted set to increment.

      • increment: number

        The score to increment the member.

      • Optionaloptions: ZAddOptions

        (Optional) The ZADD options - see ZAddOptions.

        Command Response - The score of the member. If there was a conflict with the options, the operation aborts and null is returned.

      Returns ClusterBatch

    • Returns the number of members in the sorted set stored at key with scores between minScore and maxScore.

      Parameters

      • key: GlideString

        The key of the sorted set.

      • minScore: Boundary<number>

        The minimum score to count from. Can be positive/negative infinity, or specific score and inclusivity.

      • maxScore: Boundary<number>

        The maximum score to count up to. Can be positive/negative infinity, or specific score and inclusivity.

        Command Response - The number of members in the specified score range. If key does not exist, it is treated as an empty sorted set, and the command returns 0. If minScore is greater than maxScore, 0 is returned.

      Returns ClusterBatch

    • Returns the difference between the first sorted set and all the successive sorted sets. To get the elements with their scores, see zdiffWithScores.

      Parameters

      • keys: GlideString[]

        The keys of the sorted sets.

        Command Response - An array of elements representing the difference between the sorted sets. If the first key does not exist, it is treated as an empty sorted set, and the command returns an empty array.

      Returns ClusterBatch

      Since Valkey version 6.2.0.

    • Calculates the difference between the first sorted set and all the successive sorted sets in keys and stores the difference as a sorted set to destination, overwriting it if it already exists. Non-existent keys are treated as empty sets.

      Parameters

      • destination: GlideString

        The key for the resulting sorted set.

      • keys: GlideString[]

        The keys of the sorted sets to compare.

        Command Response - The number of members in the resulting sorted set stored at destination.

      Returns ClusterBatch

      Since Valkey version 6.2.0.

    • Returns the difference between the first sorted set and all the successive sorted sets, with the associated scores.

      Parameters

      • keys: GlideString[]

        The keys of the sorted sets.

        Command Response - A list of elements and their scores representing the difference between the sorted sets. If the first key does not exist, it is treated as an empty sorted set, and the command returns an empty array. The response comes in format GlideRecord<number>, see GlideRecord.

      Returns ClusterBatch

      Since Valkey version 6.2.0.

    • Returns the cardinality of the intersection of the sorted sets specified by keys.

      Parameters

      • keys: GlideString[]

        The keys of the sorted sets to intersect.

      • Optionaloptions: { limit?: number }

        (Optional) Additional parameters:

        • (Optional) limit: the limit for the intersection cardinality value. If not specified, or set to 0, no limit is used.

        Command Response - The cardinality of the intersection of the given sorted sets.

      Returns ClusterBatch

      Since Valkey version 7.0.0.

    • Computes the intersection of sorted sets given by the specified keys and stores the result in destination. If destination already exists, it is overwritten. Otherwise, a new sorted set will be created.

      Parameters

      • destination: GlideString

        The key of the destination sorted set.

      • keys: GlideString[] | KeyWeight[]

        The keys of the sorted sets with possible formats:

        • GlideString[] - for keys only.
        • KeyWeight[] - for weighted keys with score multipliers.
      • Optionaloptions: { aggregationType?: AggregationType }

        (Optional) Additional parameters:

        • (Optional) aggregationType: the aggregation strategy to apply when combining the scores of elements. See AggregationType. If aggregationType is not specified, defaults to AggregationType.SUM.

        Command Response - The number of elements in the resulting sorted set stored at destination.

      Returns ClusterBatch

      Since Valkey version 6.2.0.

    • Computes the intersection of sorted sets given by the specified keys and returns a list of intersecting elements with scores. To get the elements only, see zinter. To store the result in a key as a sorted set, see zinterStore.

      Parameters

      • keys: GlideString[] | KeyWeight[]

        The keys of the sorted sets with possible formats:

        • GlideString[] - for keys only.
        • KeyWeight[] - for weighted keys with score multipliers.
      • Optionaloptions: { aggregationType?: AggregationType }

        (Optional) Additional parameters:

        • (Optional) aggregationType: the aggregation strategy to apply when combining the scores of elements. See AggregationType. If aggregationType is not specified, defaults to AggregationType.SUM.

        Command Response - A list of elements and their scores representing the intersection of the sorted sets. If a key does not exist, it is treated as an empty sorted set, and the command returns an empty result. The response comes in format GlideRecord<number>, see GlideRecord.

      Returns ClusterBatch

      Since Valkey version 6.2.0.

    • Pops member-score pairs from the first non-empty sorted set, with the given keys being checked in the order they are provided.

      Parameters

      • keys: GlideString[]

        The keys of the sorted sets.

      • modifier: ScoreFilter

        The element pop criteria - either ScoreFilter.MIN or ScoreFilter.MAX to pop the member with the lowest/highest score accordingly.

      • Optionalcount: number

        (Optional) The number of elements to pop. If not supplied, only one element will be popped.

        Command Response - A two-element array containing the key name of the set from which the was popped, and a GlideRecord<number> of the popped elements - see GlideRecord. If no member could be popped, returns null.

      Returns ClusterBatch

      Since Valkey version 7.0.0.

    • Removes and returns the members with the highest scores from the sorted set stored at key. If count is provided, up to count members with the highest scores are removed and returned. Otherwise, only one member with the highest score is removed and returned.

      Parameters

      • key: GlideString

        The key of the sorted set.

      • Optionalcount: number

        Specifies the quantity of members to pop. If not specified, pops one member.

        Command Response - A list of the removed members and their scores, ordered from the one with the lowest score to the one with the highest. If key doesn't exist, it will be treated as an empty sorted set and the command returns an empty map. If count is higher than the sorted set's cardinality, returns all members and their scores. The response comes in format GlideRecord<number>, see GlideRecord.

      Returns ClusterBatch

    • Removes and returns the members with the lowest scores from the sorted set stored at key. If count is provided, up to count members with the lowest scores are removed and returned. Otherwise, only one member with the lowest score is removed and returned.

      Parameters

      • key: GlideString

        The key of the sorted set.

      • Optionalcount: number

        Specifies the quantity of members to pop. If not specified, pops one member.

        Command Response - A list of the removed members and their scores, ordered from the one with the lowest score to the one with the highest. If key doesn't exist, it will be treated as an empty sorted set and the command returns an empty map. If count is higher than the sorted set's cardinality, returns all members and their scores. The response comes in format GlideRecord<number>, see GlideRecord.

      Returns ClusterBatch

    • Returns the specified range of elements with their scores in the sorted set stored at key. Similar to ZRange but with a WITHSCORE flag.

      Parameters

      • key: GlideString

        The key of the sorted set.

      • rangeQuery: RangeByScore | RangeByIndex

        The range query object representing the type of range query to perform.

      • reverse: boolean = false

        If true, reverses the sorted set, with index 0 as the element with the highest score.

        Command Response - A list of elements and their scores within the specified range. If key does not exist, it is treated as an empty sorted set, and the command returns an empty list. The response comes in format GlideRecord<number>, see GlideRecord.

      Returns ClusterBatch

    • Removes the specified members from the sorted set stored at key. Specified members that are not a member of this set are ignored.

      Parameters

      • key: GlideString

        The key of the sorted set.

      • members: GlideString[]

        A list of members to remove from the sorted set.

        Command Response - The number of members that were removed from the sorted set, not including non-existing members. If key does not exist, it is treated as an empty sorted set, and this command returns 0.

      Returns ClusterBatch

    • Removes all elements in the sorted set stored at key with rank between start and end. Both start and end are zero-based indexes with 0 being the element with the lowest score. These indexes can be negative numbers, where they indicate offsets starting at the element with the highest score.

      Parameters

      • key: GlideString

        The key of the sorted set.

      • start: number

        The starting point of the range.

      • end: number

        The end of the range.

        Command Response - The number of members removed. If start exceeds the end of the sorted set, or if start is greater than end, 0 returned. If end exceeds the actual end of the sorted set, the range will stop at the actual end of the sorted set. If key does not exist 0 will be returned.

      Returns ClusterBatch

    • Removes all elements in the sorted set stored at key with a score between minScore and maxScore.

      Parameters

      • key: GlideString

        The key of the sorted set.

      • minScore: Boundary<number>

        The minimum score to remove from. Can be negative infinity, or specific score and inclusivity.

      • maxScore: Boundary<number>

        The maximum score to remove to. Can be positive infinity, or specific score and inclusivity.

        Command Response - the number of members removed. If key does not exist, it is treated as an empty sorted set, and the command returns 0. If minScore is greater than maxScore, 0 is returned.

      Returns ClusterBatch

    • Returns the rank of member in the sorted set stored at key with its score, where scores are ordered from the highest to lowest, starting from 0.

      Parameters

      • key: GlideString

        The key of the sorted set.

      • member: GlideString

        The member whose rank is to be retrieved.

        Command Response - A list containing the rank and score of member in the sorted set, where ranks are ordered from high to low based on scores. If key doesn't exist, or if member is not present in the set, null will be returned.

      Returns ClusterBatch

      Since Valkey version 7.2.0.

    • Iterates incrementally over a sorted set.

      Parameters

      • key: GlideString

        The key of the sorted set.

      • cursor: string

        The cursor that points to the next iteration of results. A value of "0" indicates the start of the search.

      • Optionaloptions: ZScanOptions

        (Optional) The zscan options - see ZScanOptions

        Command Response - An Array of the cursor and the subset of the sorted set held by key. The first element is always the cursor for the next iteration of results. 0 will be the cursor returned on the last iteration of the sorted set. The second element is always an Array of the subset of the sorted set held in key. The Array in the second element is a flattened series of String pairs, where the value is at even indices and the score is at odd indices. If options.noScores is to true, the second element will only contain the members without scores.

      Returns ClusterBatch

    • Computes the union of sorted sets given by the specified keys and stores the result in destination. If destination already exists, it is overwritten. Otherwise, a new sorted set will be created. To get the result directly, see zunionWithScores.

      Parameters

      • destination: GlideString

        The key of the destination sorted set.

      • keys: GlideString[] | KeyWeight[]

        The keys of the sorted sets with possible formats:

        • GlideString[] - for keys only.
        • KeyWeight[] - for weighted keys with their score multipliers.
      • Optionaloptions: { aggregationType?: AggregationType }

        (Optional) Additional parameters:

        • (Optional) aggregationType: the aggregation strategy to apply when combining the scores of elements. See AggregationType. If aggregationType is not specified, defaults to AggregationType.SUM.

        Command Response - The number of elements in the resulting sorted set stored at destination.

      Returns ClusterBatch

    • Computes the intersection of sorted sets given by the specified keys and returns a list of union elements with scores. To get the elements only, see zunion.

      Parameters

      • keys: GlideString[] | KeyWeight[]

        The keys of the sorted sets with possible formats:

        • GlideString[] - for keys only.
        • KeyWeight[] - for weighted keys with their score multipliers.
      • Optionaloptions: { aggregationType?: AggregationType }

        (Optional) Additional parameters:

        • (Optional) aggregationType: the aggregation strategy to apply when combining the scores of elements. See AggregationType. If aggregationType is not specified, defaults to AggregationType.SUM.

        Command Response - A list of elements and their scores representing the intersection of the sorted sets. The response comes in format GlideRecord<number>, see GlideRecord.

      Returns ClusterBatch

      Since Valkey version 6.2.0.