Home / node / Transaction / classes / ClusterTransaction @valkey/valkey-glide
@valkey/valkey-glide / Transaction / ClusterTransaction
Class: ClusterTransaction
Extends BaseTransaction class for cluster mode commands. Transactions allow the execution of a group of commands in a single step.
Command Response: An array of command responses is returned by the GlideClusterClient.exec command, in the order they were given. Each element in the array represents a command given to the transaction. The response for each command depends on the executed Valkey command. Specific response types are documented alongside each method.
Hierarchy
Extends
BaseTransaction
\<ClusterTransaction
>
Constructors
Constructor
new ClusterTransaction():
ClusterTransaction
Returns
ClusterTransaction
Inherited from
BaseTransaction<ClusterTransaction>.constructor
Properties
commands
readonly
commands:Command
[] =[]
Internal
Inherited from
BaseTransaction.commands
setCommandsIndexes
readonly
setCommandsIndexes:number
[] =[]
Internal
Array of command indexes indicating commands that need to be converted into a Set
within the transaction.
Inherited from
BaseTransaction.setCommandsIndexes
Methods
addAndReturn()
protected
addAndReturn(command
,shouldConvertToSet
):ClusterTransaction
Adds a command to the transaction and returns the transaction instance.
Parameters
command
Command
The command to add.
shouldConvertToSet
boolean
= false
Indicates if the command should be converted to a Set
.
Returns
ClusterTransaction
The updated transaction instance.
Inherited from
BaseTransaction.addAndReturn
append()
append(
key
,value
):ClusterTransaction
Appends a value
to a key
. If key
does not exist it is created and set as an empty string,
so APPEND
will be similar to set in this special case.
Parameters
key
The key of the string.
value
The key of the string.
Command Response - The length of the string after appending the value.
Returns
ClusterTransaction
See
valkey.io for details.
Inherited from
BaseTransaction.append
bitcount()
bitcount(
key
,options?
):ClusterTransaction
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
The key for the string to count the set bits of.
options?
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
ClusterTransaction
See
valkey.io for more details.
Inherited from
BaseTransaction.bitcount
bitfield()
bitfield(
key
,subcommands
):ClusterTransaction
Reads or modifies the array of bits representing the string that is held at key
based on the specified
subcommands
.
Parameters
key
The key of the string.
subcommands
The subcommands to be performed on the binary value of the string at key
, which could be
any of the following:
Command Response - An array of results from the executed subcommands:
- BitFieldGet returns the value in BitOffset or BitOffsetMultiplier.
- BitFieldSet returns the old value in BitOffset or BitOffsetMultiplier.
- BitFieldIncrBy returns the new value in BitOffset or BitOffsetMultiplier.
- BitFieldOverflow determines the behavior of the BitFieldSet and BitFieldIncrBy subcommands when an overflow or underflow occurs. BitFieldOverflow does not return a value and does not contribute a value to the array response.
Returns
ClusterTransaction
See
valkey.io for details.
Inherited from
BaseTransaction.bitfield
bitfieldReadOnly()
bitfieldReadOnly(
key
,subcommands
):ClusterTransaction
Reads the array of bits representing the string that is held at key
based on the specified subcommands
.
Parameters
key
The key of the string.
subcommands
The BitFieldGet subcommands to be performed.
Command Response - An array of results from the BitFieldGet subcommands.
Returns
ClusterTransaction
See
valkey.io for details.
Remarks
Since Valkey version 6.0.0.
Inherited from
BaseTransaction.bitfieldReadOnly
bitop()
bitop(
operation
,destination
,keys
):ClusterTransaction
Perform a bitwise operation between multiple keys (containing string values) and store the result in the
destination
.
Parameters
operation
The bitwise operation to perform.
destination
The key that will store the resulting string.
keys
The list of keys to perform the bitwise operation on.
Command Response - The size of the string stored in destination
.
Returns
ClusterTransaction
See
valkey.io for details.
Inherited from
BaseTransaction.bitop
bitpos()
bitpos(
key
,bit
,options?
):ClusterTransaction
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
The key of the string.
bit
number
The bit value to match. Must be 0
or 1
.
options?
(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
ClusterTransaction
See
valkey.io for details.
Inherited from
BaseTransaction.bitpos
blmove()
blmove(
source
,destination
,whereFrom
,whereTo
,timeout
):ClusterTransaction
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
The key to the source list.
destination
The key to the destination list.
whereFrom
The ListDirection to remove the element from.
whereTo
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
ClusterTransaction
See
valkey.io for details.
Remarks
When in cluster mode, both source
and destination
must map to the same hash slot.
Inherited from
BaseTransaction.blmove
blmpop()
blmpop(
keys
,direction
,timeout
,count?
):ClusterTransaction
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
An array of keys to lists.
direction
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.
count?
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
ClusterTransaction
See
valkey.io for details.
Remarks
Since Valkey version 7.0.0.
Inherited from
BaseTransaction.blmpop
blpop()
blpop(
keys
,timeout
):ClusterTransaction
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
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
ClusterTransaction
See
valkey.io for details.
Remarks
BLPOP
is a blocking command, see Blocking Commands for more details and best practices.
Inherited from
BaseTransaction.blpop
brpop()
brpop(
keys
,timeout
):ClusterTransaction
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
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
ClusterTransaction
See
valkey.io for details.
Remarks
BRPOP
is a blocking command, see Blocking Commands for more details and best practices.
Inherited from
BaseTransaction.brpop
bzmpop()
bzmpop(
keys
,modifier
,timeout
,count?
):ClusterTransaction
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
The keys of the sorted sets.
modifier
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.
count?
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
ClusterTransaction
See
valkey.io for details.
Remarks
BZMPOP
is a client blocking command, see Valkey Glide Wiki for more details and best practices.
Inherited from
BaseTransaction.bzmpop
bzpopmax()
bzpopmax(
keys
,timeout
):ClusterTransaction
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
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
ClusterTransaction
See
valkey.io for details.
Inherited from
BaseTransaction.bzpopmax
bzpopmin()
bzpopmin(
keys
,timeout
):ClusterTransaction
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
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
ClusterTransaction
See
valkey.io for details.
Inherited from
BaseTransaction.bzpopmin
clientGetName()
clientGetName():
ClusterTransaction
Gets the name of the connection on which the transaction is being executed.
Returns
ClusterTransaction
See
valkey.io for details.
Command Response - The name of the client connection as a string if a name is set, or null if no name is assigned.
Inherited from
BaseTransaction.clientGetName
clientId()
clientId():
ClusterTransaction
Returns the current connection ID.
Returns
ClusterTransaction
See
valkey.io for details.
Command Response - The ID of the connection.
Inherited from
BaseTransaction.clientId
configGet()
configGet(
parameters
):ClusterTransaction
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
ClusterTransaction
See
valkey.io for details.
Inherited from
BaseTransaction.configGet
configResetStat()
configResetStat():
ClusterTransaction
Resets the statistics reported by Valkey using the INFO
and LATENCY HISTOGRAM
commands.
Returns
ClusterTransaction
See
valkey.io for details.
Command Response - always "OK".
Inherited from
BaseTransaction.configResetStat
configRewrite()
configRewrite():
ClusterTransaction
Rewrites the configuration file with the current configuration.
Returns
ClusterTransaction
See
valkey.io for details.
Command Response - "OK" when the configuration was rewritten properly. Otherwise, the transaction fails with an error.
Inherited from
BaseTransaction.configRewrite
configSet()
configSet(
parameters
):ClusterTransaction
Sets configuration parameters to the specified values. Starting from server version 7, command supports multiple parameters.
Parameters
parameters
Record
\<string
, GlideString
>
A map consisting of configuration parameters and their respective values to set.
Command Response - "OK" when the configuration was set properly. Otherwise, the transaction fails with an error.
Returns
ClusterTransaction
See
valkey.io for details.
Inherited from
BaseTransaction.configSet
copy()
copy(
source
,destination
,options?
):ClusterTransaction
Copies the value stored at the source
to the destination
key. When replace
is true,
removes the destination
key first if it already exists, otherwise performs no action.
Parameters
source
The key to the source value.
destination
The key where the value should be copied to.
options?
replace?
boolean
Returns
ClusterTransaction
See
valkey.io for details.
Remarks
Since Valkey version 6.2.0.
customCommand()
customCommand(
args
):ClusterTransaction
Executes a single command, without checking inputs. Every part of the command, including subcommands, should be added as a separate value in args.
Parameters
args
Returns
ClusterTransaction
See
Glide Wiki for details on the restrictions and limitations of the custom command API.
Command Response - A response from Valkey with an Object
.
Inherited from
BaseTransaction.customCommand
dbsize()
dbsize():
ClusterTransaction
Returns the number of keys in the currently selected database.
Returns
ClusterTransaction
See
valkey.io for details.
Command Response - The number of keys in the currently selected database.
Inherited from
BaseTransaction.dbsize
decr()
decr(
key
):ClusterTransaction
Decrements the number stored at key
by one. If key
does not exist, it is set to 0 before performing the operation.
Parameters
key
The key to decrement its value.
Command Response - the value of key
after the decrement.
Returns
ClusterTransaction
See
valkey.io for details.
Inherited from
BaseTransaction.decr
decrBy()
decrBy(
key
,amount
):ClusterTransaction
Decrements the number stored at key
by amount
. If key
does not exist, it is set to 0 before performing the operation.
Parameters
key
The key to decrement its value.
amount
number
The amount to decrement.
Command Response - the value of key
after the decrement.
Returns
ClusterTransaction
See
valkey.io for details.
Inherited from
BaseTransaction.decrBy
del()
del(
keys
):ClusterTransaction
Removes the specified keys. A key is ignored if it does not exist.
Parameters
keys
A list of keys to be deleted from the database.
Command Response - The number of keys that were removed.
Returns
ClusterTransaction
See
valkey.io for details.
Inherited from
BaseTransaction.del
dump()
dump(
key
):ClusterTransaction
Serialize the value stored at key
in a Valkey-specific format and return it to the user.
Parameters
key
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
ClusterTransaction
See
valkey.io for details.
Remarks
To execute a transaction with a dump
command, the exec
command requires Decoder.Bytes
to handle the response.
Inherited from
BaseTransaction.dump
echo()
echo(
message
):ClusterTransaction
Echoes the provided message
back
Parameters
message
The message to be echoed back.
Command Response - The provided message
.
Returns
ClusterTransaction
See
valkey.io for more details.
Inherited from
BaseTransaction.echo
exists()
exists(
keys
):ClusterTransaction
Returns the number of keys in keys
that exist in the database.
Parameters
keys
The keys list to check.
Command Response - the number of keys that exist. If the same existing key is mentioned in keys
multiple times,
it will be counted multiple times.
Returns
ClusterTransaction
See
valkey.io for details.
Inherited from
BaseTransaction.exists
expire()
expire(
key
,seconds
,options?
):ClusterTransaction
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
The key to set timeout on it.
seconds
number
The timeout in seconds.
options?
(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.
expireOption?
Returns
ClusterTransaction
See
valkey.io for details.
Inherited from
BaseTransaction.expire
expireAt()
expireAt(
key
,unixSeconds
,options?
):ClusterTransaction
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
The key to set timeout on it.
unixSeconds
number
The timeout in an absolute Unix timestamp.
options?
(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.
expireOption?
Returns
ClusterTransaction
See
valkey.io for details.
Inherited from
BaseTransaction.expireAt
expireTime()
expireTime(
key
):ClusterTransaction
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
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
ClusterTransaction
See
valkey.io for details.
Remarks
Since Valkey version 7.0.0.
Inherited from
BaseTransaction.expireTime
fcall()
fcall(
func
,keys
,args
):ClusterTransaction
Invokes a previously loaded function.
Parameters
func
The function name.
keys
A list of keys
accessed by the function. To ensure the correct execution of functions,
all names of keys that a function accesses must be explicitly provided as keys
.
args
A list of function
arguments and it should not represent names of keys.
Command Response - The invoked function's return value.
Returns
ClusterTransaction
See
valkey.io for details.
Remarks
Since Valkey version 7.0.0.
Inherited from
BaseTransaction.fcall
fcallReadonly()
fcallReadonly(
func
,keys
,args
):ClusterTransaction
Invokes a previously loaded read-only function.
Parameters
func
The function name.
keys
A list of keys
accessed by the function. To ensure the correct execution of functions,
all names of keys that a function accesses must be explicitly provided as keys
.
args
A list of function
arguments and it should not represent names of keys.
Command Response - The invoked function's return value.
Returns
ClusterTransaction
See
valkey.io for details.
Remarks
Since Valkey version 7.0.0.
Inherited from
BaseTransaction.fcallReadonly
flushall()
flushall(
mode?
):ClusterTransaction
Deletes all the keys of all the existing databases. This command never fails.
Parameters
mode?
(Optional) The flushing mode, could be either FlushMode.SYNC or FlushMode.ASYNC.
Command Response - "OK"
.
Returns
ClusterTransaction
See
valkey.io for details.
Inherited from
BaseTransaction.flushall
flushdb()
flushdb(
mode?
):ClusterTransaction
Deletes all the keys of the currently selected database. This command never fails.
Parameters
mode?
(Optional) The flushing mode, could be either FlushMode.SYNC or FlushMode.ASYNC.
Command Response - "OK"
.
Returns
ClusterTransaction
See
valkey.io for details.
Inherited from
BaseTransaction.flushdb
functionDelete()
functionDelete(
libraryCode
):ClusterTransaction
Deletes a library and all its functions.
Parameters
libraryCode
The library name to delete.
Command Response - "OK"
.
Returns
ClusterTransaction
See
valkey.io for details.
Remarks
Since Valkey version 7.0.0.
Inherited from
BaseTransaction.functionDelete
functionDump()
functionDump():
ClusterTransaction
Returns the serialized payload of all loaded libraries.
Returns
ClusterTransaction
See
valkey.io for details.
Remarks
Since Valkey version 7.0.0.
Inherited from
BaseTransaction.functionDump
functionFlush()
functionFlush(
mode?
):ClusterTransaction
Deletes all function libraries.
Parameters
mode?
(Optional) The flushing mode, could be either FlushMode.SYNC or FlushMode.ASYNC.
Command Response - "OK"
.
Returns
ClusterTransaction
See
valkey.io for details.
Remarks
Since Valkey version 7.0.0.
Inherited from
BaseTransaction.functionFlush
functionList()
functionList(
options?
):ClusterTransaction
Returns information about the functions and libraries.
Parameters
options?
(Optional) Parameters to filter and request additional info.
Command Response - Info about all or selected libraries and their functions in FunctionListResponse format.
Returns
ClusterTransaction
See
valkey.io for details.
Remarks
Since Valkey version 7.0.0.
Inherited from
BaseTransaction.functionList
functionLoad()
functionLoad(
libraryCode
,replace?
):ClusterTransaction
Loads a library to Valkey.
Parameters
libraryCode
The source code that implements the library.
replace?
boolean
(Optional) Whether the given library should overwrite a library with the same name if it already exists.
Command Response - The library name that was loaded.
Returns
ClusterTransaction
See
valkey.io for details.
Remarks
Since Valkey version 7.0.0.
Inherited from
BaseTransaction.functionLoad
functionRestore()
functionRestore(
payload
,policy?
):ClusterTransaction
Restores libraries from the serialized payload returned by functionDump.
Parameters
payload
Buffer
The serialized data from functionDump.
policy?
(Optional) A policy for handling existing libraries.
Command Response - "OK"
.
Returns
ClusterTransaction
See
valkey.io for details.
Remarks
Since Valkey version 7.0.0.
Inherited from
BaseTransaction.functionRestore
functionStats()
functionStats():
ClusterTransaction
Returns information about the function that's currently running and information about the available execution engines.
Returns
ClusterTransaction
See
valkey.io for details.
Remarks
Since Valkey version 7.0.0.
Command Response - A Record
of type FunctionStatsSingleResponse with two keys:
"running_script"
with information about the running script."engines"
with information about available engines and their stats.
Inherited from
BaseTransaction.functionStats
geoadd()
geoadd(
key
,membersToGeospatialData
,options?
):ClusterTransaction
Adds geospatial members with their positions to the specified sorted set stored at key
.
If a member is already a part of the sorted set, its position is updated.
Parameters
key
The key of the sorted set.
membersToGeospatialData
Map
\<GlideString
, GeospatialData
>
A mapping of member names to their corresponding positions - see GeospatialData. The command will report an error when the user attempts to index coordinates outside the specified ranges.
options?
The GeoAdd options - see GeoAddOptions.
Command Response - The number of elements added to the sorted set. If changed
is set to
true
in the options, returns the number of elements updated in the sorted set.
Returns
ClusterTransaction
See
valkey.io for details.
Inherited from
BaseTransaction.geoadd
geodist()
geodist(
key
,member1
,member2
,options?
):ClusterTransaction
Returns the distance between member1
and member2
saved in the geospatial index stored at key
.
Parameters
key
The key of the sorted set.
member1
The name of the first member.
member2
The name of the second member.
options?
(Optional) Additional parameters:
- (Optional) unit
: the unit of distance measurement - see GeoUnit.
If not specified, the GeoUnit.METERS is used as a default unit.
Command Response - The distance between member1
and member2
. Returns null
, if one or both members do not exist,
or if the key does not exist.
unit?
Returns
ClusterTransaction
See
valkey.io for details.
Inherited from
BaseTransaction.geodist
geohash()
geohash(
key
,members
):ClusterTransaction
Returns the GeoHash
strings representing the positions of all the specified members
in the sorted set stored at key
.
Parameters
key
The key of the sorted set.
members
The array of members whose GeoHash
strings are to be retrieved.
Command Response - An array of GeoHash
strings representing the positions of the specified members stored at key
.
If a member does not exist in the sorted set, a null
value is returned for that member.
Returns
ClusterTransaction
See
valkey.io for details.
Inherited from
BaseTransaction.geohash
geopos()
geopos(
key
,members
):ClusterTransaction
Returns the positions (longitude, latitude) of all the specified members
of the
geospatial index represented by the sorted set at key
.
Parameters
key
The key of the sorted set.
members
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
ClusterTransaction
See
valkey.io for more details.
Inherited from
BaseTransaction.geopos
geosearch()
geosearch(
key
,searchFrom
,searchBy
,resultOptions?
):ClusterTransaction
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
The key of the sorted set.
searchFrom
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
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.
resultOptions?
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 forsearchBy
. - The geohash of the location as a integer
number
. - The coordinates as a two item
array
of floating pointnumber
s.
Returns
ClusterTransaction
See
valkey.io for details.
Remarks
Since Valkey version 6.2.0.
Inherited from
BaseTransaction.geosearch
geosearchstore()
geosearchstore(
destination
,source
,searchFrom
,searchBy
,resultOptions?
):ClusterTransaction
Searches for members in a sorted set stored at source
representing geospatial data
within a circular or rectangular area 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 geosearch.
Parameters
destination
The key of the destination sorted set.
source
The key of the sorted set.
searchFrom
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
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.
resultOptions?
(Optional) Parameters to request additional information and configure sorting/limiting the results, see GeoSearchStoreResultOptions.
Command Response - The number of elements in the resulting sorted set stored at destination
.
Returns
ClusterTransaction
See
valkey.io for details.
Remarks
Since Valkey version 6.2.0.
Inherited from
BaseTransaction.geosearchstore
get()
get(
key
):ClusterTransaction
Get the value associated with the given key, or null if no such value exists.
Parameters
key
The key to retrieve from the database.
Command Response - If key
exists, returns the value of key
. Otherwise, return null.
Returns
ClusterTransaction
See
valkey.io for details.
Inherited from
BaseTransaction.get
getbit()
getbit(
key
,offset
):ClusterTransaction
Returns the bit value at offset
in the string value stored at key
. offset
must be greater than or equal
to zero.
Parameters
key
The key of the string.
offset
number
The index of the bit to return.
Command Response - The bit at the given offset
of the string. Returns 0
if the key is empty or if the
offset
exceeds the length of the string.
Returns
ClusterTransaction
See
valkey.io for details.
Inherited from
BaseTransaction.getbit
getdel()
getdel(
key
):ClusterTransaction
Gets a string value associated with the given key
and deletes the key.
Parameters
key
The key to retrieve from the database.
Command Response - If key
exists, returns the value
of key
. Otherwise, return null
.
Returns
ClusterTransaction
See
valkey.io for details.
Inherited from
BaseTransaction.getdel
getex()
getex(
key
,options?
):ClusterTransaction
Get the value of key
and optionally set its expiration. GETEX
is similar to get.
Parameters
key
The key to retrieve from the database.
options?
(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
.
{ duration
: number
; type
: TimeUnit
; } | "persist"
Returns
ClusterTransaction
See
valkey.io for more details.
Remarks
Since Valkey version 6.2.0.
Inherited from
BaseTransaction.getex
getrange()
getrange(
key
,start
,end
):ClusterTransaction
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
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
ClusterTransaction
See
valkey.io for details.
Inherited from
BaseTransaction.getrange
hdel()
hdel(
key
,fields
):ClusterTransaction
Removes the specified fields from the hash stored at key
.
Specified fields that do not exist within this hash are ignored.
Parameters
key
The key of the hash.
fields
The fields to remove from the hash stored at key
.
Command Response - the number of fields that were removed from the hash, not including specified but non existing fields.
If key
does not exist, it is treated as an empty hash and it returns 0.
Returns
ClusterTransaction
See
valkey.io for details.
Inherited from
BaseTransaction.hdel
hexists()
hexists(
key
,field
):ClusterTransaction
Returns if field
is an existing field in the hash stored at key
.
Parameters
key
The key of the hash.
field
The field to check in the hash stored at key
.
Command Response - true
if the hash contains field
. If the hash does not contain field
, or if key
does not exist,
the command response will be false
.
Returns
ClusterTransaction
See
valkey.io for details.
Inherited from
BaseTransaction.hexists
hget()
hget(
key
,field
):ClusterTransaction
Retrieve the value associated with field
in the hash stored at key
.
Parameters
key
The key of the hash.
field
The field in the hash stored at key
to retrieve from the database.
Command Response - the value associated with field
, or null when field
is not present in the hash or key
does not exist.
Returns
ClusterTransaction
See
valkey.io for details.
Inherited from
BaseTransaction.hget
hgetall()
hgetall(
key
):ClusterTransaction
Returns all fields and values of the hash stored at key
.
Parameters
key
The key of the hash.
Command Response - A list of fields and their values stored in the hash.
If key
does not exist, it returns an empty list.
Returns
ClusterTransaction
See
valkey.io for details.
Inherited from
BaseTransaction.hgetall
hincrBy()
hincrBy(
key
,field
,amount
):ClusterTransaction
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
The key of the hash.
field
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
ClusterTransaction
See
valkey.io for details.
Inherited from
BaseTransaction.hincrBy
hincrByFloat()
hincrByFloat(
key
,field
,amount
):ClusterTransaction
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
The key of the hash.
field
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
ClusterTransaction
See
valkey.io for details.
Inherited from
BaseTransaction.hincrByFloat
hkeys()
hkeys(
key
):ClusterTransaction
Returns all field names in the hash stored at key
.
Parameters
key
The key of the hash.
Command Response - A list of field names for the hash, or an empty list when the key does not exist.
Returns
ClusterTransaction
See
valkey.io for details.
Inherited from
BaseTransaction.hkeys
hlen()
hlen(
key
):ClusterTransaction
Returns the number of fields contained in the hash stored at key
.
Parameters
key
The key of the hash.
Command Response - The number of fields in the hash, or 0 when the key does not exist.
Returns
ClusterTransaction
See
valkey.io for details.
Inherited from
BaseTransaction.hlen
hmget()
hmget(
key
,fields
):ClusterTransaction
Returns the values associated with the specified fields in the hash stored at key
.
Parameters
key
The key of the hash.
fields
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
ClusterTransaction
See
valkey.io for details.
Inherited from
BaseTransaction.hmget
hrandfield()
hrandfield(
key
):ClusterTransaction
Returns a random field name from the hash value stored at key
.
Parameters
key
The key of the hash.
Command Response - A random field name from the hash stored at key
, or null
when
the key does not exist.
Returns
ClusterTransaction
See
valkey.io for details.
Remarks
Since Valkey version 6.2.0.
Inherited from
BaseTransaction.hrandfield
hrandfieldCount()
hrandfieldCount(
key
,count
):ClusterTransaction
Retrieves up to count
random field names from the hash value stored at key
.
Parameters
key
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
ClusterTransaction
See
valkey.io for details.
Remarks
Since Valkey version 6.2.0.
Inherited from
BaseTransaction.hrandfieldCount
hrandfieldWithValues()
hrandfieldWithValues(
key
,count
):ClusterTransaction
Retrieves up to count
random field names along with their values from the hash
value stored at key
.
Parameters
key
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
ClusterTransaction
See
valkey.io for details.
Remarks
Since Valkey version 6.2.0.
Inherited from
BaseTransaction.hrandfieldWithValues
hscan()
hscan(
key
,cursor
,options?
):ClusterTransaction
Iterates incrementally over a hash.
Parameters
key
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.
options?
(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
ClusterTransaction
See
valkey.io for more details.
Inherited from
BaseTransaction.hscan
hset()
hset(
key
,fieldsAndValues
):ClusterTransaction
Sets the specified fields to their respective values in the hash stored at key
.
Parameters
key
The key of the hash.
fieldsAndValues
Record
\<string
, GlideString
> | HashDataType
Returns
ClusterTransaction
See
valkey.io for details.
Inherited from
BaseTransaction.hset
hsetnx()
hsetnx(
key
,field
,value
):ClusterTransaction
Sets field
in the hash stored at key
to value
, only if field
does not yet exist.
If key
does not exist, a new key holding a hash is created.
If field
already exists, this operation has no effect.
Parameters
key
The key of the hash.
field
The field to set the value for.
value
The value to set.
Command Response - true
if the field was set, false
if the field already existed and was not set.
Returns
ClusterTransaction
See
valkey.io for details.
Inherited from
BaseTransaction.hsetnx
hstrlen()
hstrlen(
key
,field
):ClusterTransaction
Returns the string length of the value associated with field
in the hash stored at key
.
Parameters
key
The key of the hash.
field
The field in the hash.
Command Response - The string length or 0
if field
or key
does not exist.
Returns
ClusterTransaction
See
valkey.io for details.
Inherited from
BaseTransaction.hstrlen
hvals()
hvals(
key
):ClusterTransaction
Returns all values in the hash stored at key.
Parameters
key
The key of the hash.
Command Response - a list of values in the hash, or an empty list when the key does not exist.
Returns
ClusterTransaction
See
valkey.io for details.
Inherited from
BaseTransaction.hvals
incr()
incr(
key
):ClusterTransaction
Increments the number stored at key
by one. If key
does not exist, it is set to 0 before performing the operation.
Parameters
key
The key to increment its value.
Command Response - the value of key
after the increment.
Returns
ClusterTransaction
See
valkey.io for details.
Inherited from
BaseTransaction.incr
incrBy()
incrBy(
key
,amount
):ClusterTransaction
Increments the number stored at key
by amount
. If key
does not exist, it is set to 0 before performing the operation.
Parameters
key
The key to increment its value.
amount
number
The amount to increment.
Command Response - the value of key
after the increment.
Returns
ClusterTransaction
See
valkey.io for details.
Inherited from
BaseTransaction.incrBy
incrByFloat()
incrByFloat(
key
,amount
):ClusterTransaction
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
The key to increment its value.
amount
number
The amount to increment.
Command Response - the value of key
after the increment.
Returns
ClusterTransaction
See
valkey.io for details.
Inherited from
BaseTransaction.incrByFloat
info()
info(
sections?
):ClusterTransaction
Gets information and statistics about the server.
Parameters
sections?
(Optional) A list of InfoOptions values specifying which sections of information to retrieve. When no parameter is provided, Default is assumed.
Command Response - A string containing the information for the sections requested.
Returns
ClusterTransaction
See
valkey.io for details.
Inherited from
BaseTransaction.info
lastsave()
lastsave():
ClusterTransaction
Returns UNIX TIME
of the last DB save timestamp or startup timestamp if no save
was made since then.
Returns
ClusterTransaction
See
valkey.io for details.
Command Response - UNIX TIME
of the last DB save executed with success.
Inherited from
BaseTransaction.lastsave
lcs()
lcs(
key1
,key2
):ClusterTransaction
Returns all the longest common subsequences combined between strings stored at key1
and key2
.
Parameters
key1
The key that stores the first string.
key2
The key that stores the second string.
Command Response - A String
containing all the longest common subsequence combined between the 2 strings.
An empty String
is returned if the keys do not exist or have no common subsequences.
Returns
ClusterTransaction
See
valkey.io for details.
Remarks
Since Valkey version 7.0.0.
Inherited from
BaseTransaction.lcs
lcsIdx()
lcsIdx(
key1
,key2
,options?
):ClusterTransaction
Returns the indices and lengths of the longest common subsequences between strings stored at
key1
and key2
.
Parameters
key1
The key that stores the first string.
key2
The key that stores the second string.
options?
(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 [lcsIdx](../../BaseClient/classes/BaseClient.md#lcsidx) for more details.
minMatchLen?
number
withMatchLen?
boolean
Returns
ClusterTransaction
See
valkey.io for details.
Remarks
Since Valkey version 7.0.0.
Inherited from
BaseTransaction.lcsIdx
lcsLen()
lcsLen(
key1
,key2
):ClusterTransaction
Returns the total length of all the longest common subsequences between strings stored at key1
and key2
.
Parameters
key1
The key that stores the first string.
key2
The key that stores the second string.
Command Response - The total length of all the longest common subsequences between the 2 strings.
Returns
ClusterTransaction
See
valkey.io for details.
Remarks
Since Valkey version 7.0.0.
Inherited from
BaseTransaction.lcsLen
lindex()
lindex(
key
,index
):ClusterTransaction
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
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
ClusterTransaction
See
valkey.io for details.
Inherited from
BaseTransaction.lindex
linsert()
linsert(
key
,position
,pivot
,element
):ClusterTransaction
Inserts element
in the list at key
either before or after the pivot
.
Parameters
key
The key of the list.
position
The relative position to insert into - either InsertPosition.Before
or
InsertPosition.After
the pivot
.
pivot
An element of the list.
element
The new element to insert.
Command Response - The list length after a successful insert operation.
If the key
doesn't exist returns -1
.
If the pivot
wasn't found, returns 0
.
Returns
ClusterTransaction
See
valkey.io for details.
Inherited from
BaseTransaction.linsert
llen()
llen(
key
):ClusterTransaction
Returns the length of the list stored at key
.
Parameters
key
The key of the list.
Command Response - the length of the list at key
.
If key
does not exist, it is interpreted as an empty list and 0 is returned.
Returns
ClusterTransaction
See
valkey.io for details.
Inherited from
BaseTransaction.llen
lmove()
lmove(
source
,destination
,whereFrom
,whereTo
):ClusterTransaction
Atomically pops 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
, see ListDirection.
Parameters
source
The key to the source list.
destination
The key to the destination list.
whereFrom
The ListDirection to remove the element from.
whereTo
The ListDirection to add the element to.
Command Response - The popped element, or null
if source
does not exist.
Returns
ClusterTransaction
See
valkey.io for details.
Remarks
Since Valkey version 6.2.0.
Inherited from
BaseTransaction.lmove
lmpop()
lmpop(
keys
,direction
,count?
):ClusterTransaction
Pops one or more elements from the first non-empty list from the provided keys
.
Parameters
keys
An array of keys to lists.
direction
The direction based on which elements are popped from - see ListDirection.
count?
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.
Returns
ClusterTransaction
See
valkey.io for details.
Remarks
Since Valkey version 7.0.0.
Inherited from
BaseTransaction.lmpop
lolwut()
lolwut(
options?
):ClusterTransaction
Displays a piece of generative computer art and the server version.
Parameters
options?
(Optional) The LOLWUT options - see LolwutOptions.
Command Response - A piece of generative computer art along with the current server version.
Returns
ClusterTransaction
See
valkey.io for details.
Inherited from
BaseTransaction.lolwut
lpop()
lpop(
key
):ClusterTransaction
Removes and returns the first elements of the list stored at key
.
The command pops a single element from the beginning of the list.
Parameters
key
The key of the list.
Command Response - The value of the first element.
If key
does not exist null will be returned.
Returns
ClusterTransaction
See
valkey.io for details.
Inherited from
BaseTransaction.lpop
lpopCount()
lpopCount(
key
,count
):ClusterTransaction
Removes and returns up to count
elements of the list stored at key
, depending on the list's length.
Parameters
key
The key of the list.
count
number
The count of the elements to pop from the list.
Command Response - A list of the popped elements will be returned depending on the list's length.
If key
does not exist null will be returned.
Returns
ClusterTransaction
See
valkey.io for details.
Inherited from
BaseTransaction.lpopCount
lpos()
lpos(
key
,element
,options?
):ClusterTransaction
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
The name of the list.
element
The value to search for within the list.
options?
(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
ClusterTransaction
See
valkey.io for details.
Remarks
Since Valkey version 6.0.6.
Inherited from
BaseTransaction.lpos
lpush()
lpush(
key
,elements
):ClusterTransaction
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
The key of the list.
elements
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
ClusterTransaction
See
valkey.io for details.
Inherited from
BaseTransaction.lpush
lpushx()
lpushx(
key
,elements
):ClusterTransaction
Inserts specified values at the head of the list
, only if key
already
exists and holds a list.
Parameters
key
The key of the list.
elements
The elements to insert at the head of the list stored at key
.
Command Response - The length of the list after the push operation.
Returns
ClusterTransaction
See
valkey.io for details.
Inherited from
BaseTransaction.lpushx
lrange()
lrange(
key
,start
,end
):ClusterTransaction
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
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
ClusterTransaction
See
valkey.io for details.
Inherited from
BaseTransaction.lrange
lrem()
lrem(
key
,count
,element
):ClusterTransaction
Removes the first count
occurrences of elements equal to element
from the list stored at key
.
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
.
Parameters
key
The key of the list.
count
number
The count of the occurrences of elements equal to element
to remove.
element
The element to remove from the list.
Command Response - the number of the removed elements.
If key
does not exist, 0 is returned.
Returns
ClusterTransaction
Inherited from
BaseTransaction.lrem
lset()
lset(
key
,index
,element
):ClusterTransaction
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
The key of the list.
index
number
The index of the element in the list to be set.
element
The new element to set at the specified index.
Command Response - Always "OK".
Returns
ClusterTransaction
See
valkey.io for details.
Inherited from
BaseTransaction.lset
ltrim()
ltrim(
key
,start
,end
):ClusterTransaction
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
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 result will be an empty list (which causes key to be 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
ClusterTransaction
See
valkey.io for details.
Inherited from
BaseTransaction.ltrim
mget()
mget(
keys
):ClusterTransaction
Retrieve the values of multiple keys.
Parameters
keys
A list of keys to retrieve values for.
Command Response - A list of values corresponding to the provided keys. If a key is not found, its corresponding value in the list will be null.
Returns
ClusterTransaction
See
valkey.io for details.
Inherited from
BaseTransaction.mget
mset()
mset(
keysAndValues
):ClusterTransaction
Set multiple keys to multiple values in a single atomic operation.
Parameters
keysAndValues
A list of key-value pairs to set.
Command Response - always "OK".
Record
\<string
, GlideString
> | GlideRecord
\<GlideString
>
Returns
ClusterTransaction
See
valkey.io for details.
Inherited from
BaseTransaction.mset
msetnx()
msetnx(
keysAndValues
):ClusterTransaction
Sets multiple keys to values if the key does not exist. The operation is atomic, and if one or more keys already exist, the entire operation fails.
Parameters
keysAndValues
A list of key-value pairs to set.
Command Response - true
if all keys were set. false
if no key was set.
Record
\<string
, GlideString
> | GlideRecord
\<GlideString
>
Returns
ClusterTransaction
See
valkey.io for details.
Inherited from
BaseTransaction.msetnx
objectEncoding()
objectEncoding(
key
):ClusterTransaction
Returns the internal encoding for the Valkey object stored at key
.
Parameters
key
The key
of the object to get the internal encoding of.
Command Response - If key
exists, returns the internal encoding of the object stored at key
as a string.
Otherwise, returns None.
Returns
ClusterTransaction
See
valkey.io for more details.
Inherited from
BaseTransaction.objectEncoding
objectFreq()
objectFreq(
key
):ClusterTransaction
Returns the logarithmic access frequency counter of a Valkey object stored at key
.
Parameters
key
The key
of the object to get the logarithmic access frequency counter of.
Command Response - If key
exists, returns the logarithmic access frequency counter of
the object stored at key
as a number
. Otherwise, returns null
.
Returns
ClusterTransaction
See
valkey.io for more details.
Inherited from
BaseTransaction.objectFreq
objectIdletime()
objectIdletime(
key
):ClusterTransaction
Returns the time in seconds since the last access to the value stored at key
.
Parameters
key
The key of the object to get the idle time of.
Command Response - If key
exists, returns the idle time in seconds. Otherwise, returns null
.
Returns
ClusterTransaction
See
valkey.io for details.
Inherited from
BaseTransaction.objectIdletime
objectRefcount()
objectRefcount(
key
):ClusterTransaction
Returns the reference count of the object stored at key
.
Parameters
key
The key
of the object to get the reference count of.
Command Response - If key
exists, returns the reference count of the object stored at key
as a number
.
Otherwise, returns null
.
Returns
ClusterTransaction
See
valkey.io for details.
Inherited from
BaseTransaction.objectRefcount
persist()
persist(
key
):ClusterTransaction
Removes the existing timeout on key
, turning the key from volatile (a key with an expire set) to
persistent (a key that will never expire as no timeout is associated).
Parameters
key
The key to remove the existing timeout on.
Command Response - false
if key
does not exist or does not have an associated timeout, true
if the timeout has been removed.
Returns
ClusterTransaction
See
valkey.io for details.
Inherited from
BaseTransaction.persist
pexpire()
pexpire(
key
,milliseconds
,options?
):ClusterTransaction
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
The key to set timeout on it.
milliseconds
number
The timeout in milliseconds.
options?
(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.
expireOption?
Returns
ClusterTransaction
See
valkey.io for details.
Inherited from
BaseTransaction.pexpire
pexpireAt()
pexpireAt(
key
,unixMilliseconds
,options?
):ClusterTransaction
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
The key to set timeout on it.
unixMilliseconds
number
The timeout in an absolute Unix timestamp.
options?
(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.
expireOption?
Returns
ClusterTransaction
See
valkey.io for details.
Inherited from
BaseTransaction.pexpireAt
pexpireTime()
pexpireTime(
key
):ClusterTransaction
Returns the absolute Unix timestamp (since January 1, 1970) at which the given key
will expire, in milliseconds.
Parameters
key
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
ClusterTransaction
See
valkey.io for details.
Remarks
Since Valkey version 7.0.0.
Inherited from
BaseTransaction.pexpireTime
pfadd()
pfadd(
key
,elements
):ClusterTransaction
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
The key of the HyperLogLog data structure to add elements into.
elements
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 1
. Otherwise, returns 0
.
Returns
ClusterTransaction
See
valkey.io for details.
Inherited from
BaseTransaction.pfadd
pfcount()
pfcount(
keys
):ClusterTransaction
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
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
ClusterTransaction
See
valkey.io for details.
Inherited from
BaseTransaction.pfcount
pfmerge()
pfmerge(
destination
,sourceKeys
):ClusterTransaction
Merges multiple HyperLogLog values into a unique value. If the destination variable exists, it is treated as one of the source HyperLogLog data sets, otherwise a new HyperLogLog is created.
Parameters
destination
The key of the destination HyperLogLog where the merged data sets will be stored.
sourceKeys
The keys of the HyperLogLog structures to be merged. Command Response - A simple "OK" response.
Returns
ClusterTransaction
See
valkey.io for details.
Inherited from
BaseTransaction.pfmerge
ping()
ping(
message?
):ClusterTransaction
Pings the server.
Parameters
message?
(Optional) A message to include in the PING command.
- If not provided, the server will respond with "PONG"
.
- If provided, the server will respond with a copy of the message.
Command Response - "PONG"
if message
is not provided, otherwise return a copy of message
.
Returns
ClusterTransaction
See
valkey.io for details.
Inherited from
BaseTransaction.ping
pttl()
pttl(
key
):ClusterTransaction
Returns the remaining time to live of key
that has a timeout, in milliseconds.
Parameters
key
The key to return its timeout.
Command Response - TTL in milliseconds, -2
if key
does not exist, -1
if key
exists but has no associated expire.
Returns
ClusterTransaction
See
valkey.io for more details.
Inherited from
BaseTransaction.pttl
publish()
publish(
message
,channel
,sharded
):ClusterTransaction
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
Message to publish.
channel
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
ClusterTransaction
See
[valkey.io](https://valkey.io/commands/publish](https://valkey.io/commands/publish) and https://valkey.io/commands/spublish for more details.
pubsubChannels()
pubsubChannels(
pattern?
):ClusterTransaction
Lists the currently active channels. The command is routed to all nodes, and aggregates the response to a single array.
Parameters
pattern?
A glob-style pattern to match active channels. If not provided, all active channels are returned. Command Response - A list of currently active channels matching the given pattern. If no pattern is specified, all active channels are returned.
Returns
ClusterTransaction
See
[https://valkey.io/commands/pubsub-channels/) for more details.
Inherited from
BaseTransaction.pubsubChannels
pubsubNumPat()
pubsubNumPat():
ClusterTransaction
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
ClusterTransaction
See
valkey.io for more details.
Command Response - The number of unique patterns.
Inherited from
BaseTransaction.pubsubNumPat
pubsubNumSub()
pubsubNumSub(
channels
):ClusterTransaction
Returns the number of subscribers (exclusive of clients subscribed to patterns) for the specified channels.
Parameters
channels
The list of channels to query for the number of subscribers.
Command Response - A list of the channel names and their numbers of subscribers.
Returns
ClusterTransaction
See
valkey.io for more details.
Inherited from
BaseTransaction.pubsubNumSub
pubsubShardChannels()
pubsubShardChannels(
pattern?
):ClusterTransaction
Lists the currently active shard channels. The command is routed to all nodes, and aggregates the response to a single array.
Parameters
pattern?
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
ClusterTransaction
See
valkey.io for more details.
pubsubShardNumSub()
pubsubShardNumSub(
channels
):ClusterTransaction
Returns the number of subscribers (exclusive of clients subscribed to patterns) for the specified shard channels.
Parameters
channels
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
ClusterTransaction
See
valkey.io for more details.
Remarks
The command is routed to all nodes, and aggregates the response into a single list.
randomKey()
randomKey():
ClusterTransaction
Returns a random existing key name from the currently selected database.
Returns
ClusterTransaction
See
valkey.io for details.
Command Response - A random existing key name from the currently selected database.
Inherited from
BaseTransaction.randomKey
rename()
rename(
key
,newKey
):ClusterTransaction
Renames key
to newkey
.
If newkey
already exists it is overwritten.
Parameters
key
The key to rename.
newKey
The new name of the key.
Command Response - If the key
was successfully renamed, return "OK". If key
does not exist, an error is thrown.
Returns
ClusterTransaction
See
valkey.io for details.
Inherited from
BaseTransaction.rename
renamenx()
renamenx(
key
,newKey
):ClusterTransaction
Renames key
to newkey
if newkey
does not yet exist.
Parameters
key
The key to rename.
newKey
The new name of the key.
Command Response - If the key
was successfully renamed, returns true
. Otherwise, returns false
.
If key
does not exist, an error is thrown.
Returns
ClusterTransaction
See
valkey.io for details.
Inherited from
BaseTransaction.renamenx
restore()
restore(
key
,ttl
,value
,options?
):ClusterTransaction
Create a key
associated with a value
that is obtained by deserializing the provided
serialized value
(obtained via dump).
Parameters
key
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
.
options?
(Optional) Restore options RestoreOptions.
Command Response - Return "OK" if the key
was successfully restored with a value
.
Returns
ClusterTransaction
See
valkey.io for details.
Remarks
options.idletime
and options.frequency
modifiers cannot be set at the same time.
Inherited from
BaseTransaction.restore
rpop()
rpop(
key
):ClusterTransaction
Removes and returns the last elements of the list stored at key
.
The command pops a single element from the end of the list.
Parameters
key
The key of the list.
Command Response - The value of the last element.
If key
does not exist null will be returned.
Returns
ClusterTransaction
See
valkey.io for details.
Inherited from
BaseTransaction.rpop
rpopCount()
rpopCount(
key
,count
):ClusterTransaction
Removes and returns up to count
elements from the list stored at key
, depending on the list's length.
Parameters
key
The key of the list.
count
number
The count of the elements to pop from the list.
Command Response - A list of popped elements will be returned depending on the list's length.
If key
does not exist null will be returned.
Returns
ClusterTransaction
See
valkey.io for details.
Inherited from
BaseTransaction.rpopCount
rpush()
rpush(
key
,elements
):ClusterTransaction
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
The key of the list.
elements
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
ClusterTransaction
See
valkey.io for details.
Inherited from
BaseTransaction.rpush
rpushx()
rpushx(
key
,elements
):ClusterTransaction
Inserts specified values at the tail of the list
, only if key
already
exists and holds a list.
Parameters
key
The key of the list.
elements
The elements to insert at the tail of the list stored at key
.
Command Response - The length of the list after the push operation.
Returns
ClusterTransaction
See
valkey.io for details.
Inherited from
BaseTransaction.rpushx
sadd()
sadd(
key
,members
):ClusterTransaction
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
The key to store the members to its set.
members
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
ClusterTransaction
See
valkey.io for details.
Inherited from
BaseTransaction.sadd
scard()
scard(
key
):ClusterTransaction
Returns the set cardinality (number of elements) of the set stored at key
.
Parameters
key
The key to return the number of its members.
Command Response - the cardinality (number of elements) of the set, or 0 if key does not exist.
Returns
ClusterTransaction
See
valkey.io for details.
Inherited from
BaseTransaction.scard
sdiff()
sdiff(
keys
):ClusterTransaction
Computes the difference between the first set and all the successive sets in keys
.
Parameters
keys
The keys of the sets to diff.
Command Response - A Set
of elements representing the difference between the sets.
If a key in keys
does not exist, it is treated as an empty set.
Returns
ClusterTransaction
See
valkey.io for details.
Inherited from
BaseTransaction.sdiff
sdiffstore()
sdiffstore(
destination
,keys
):ClusterTransaction
Stores the difference between the first set and all the successive sets in keys
into a new set at destination
.
Parameters
destination
The key of the destination set.
keys
The keys of the sets to diff.
Command Response - The number of elements in the resulting set.
Returns
ClusterTransaction
See
valkey.io for details.
Inherited from
BaseTransaction.sdiffstore
set()
set(
key
,value
,options?
):ClusterTransaction
Set the given key with the given value. Return value is dependent on the passed options.
Parameters
key
The key to store.
value
The value to store with the given key.
options?
The set options.
Command Response - If the value is successfully set, return OK.
If value
isn't set because of onlyIfExists
or onlyIfDoesNotExist
conditions, return null.
If returnOldValue
is set, return the old value as a string.
Returns
ClusterTransaction
See
valkey.io for details.
Inherited from
BaseTransaction.set
setbit()
setbit(
key
,offset
,value
):ClusterTransaction
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
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
ClusterTransaction
See
valkey.io for details.
Inherited from
BaseTransaction.setbit
setrange()
setrange(
key
,offset
,value
):ClusterTransaction
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
The key of the string to update.
offset
number
The byte position in the string where value
should be written.
value
The string written with offset
.
Command Response - The length of the string stored at key
after it was modified.
Returns
ClusterTransaction
See
valkey.io for details.
Inherited from
BaseTransaction.setrange
sinter()
sinter(
keys
):ClusterTransaction
Gets the intersection of all the given sets.
When in cluster mode, all keys
must map to the same hash slot.
Parameters
keys
The keys
of the sets to get the intersection.
Command Response - A set of members which are present in all given sets. If one or more sets do not exist, an empty set will be returned.
Returns
ClusterTransaction
See
valkey.io for details.
Inherited from
BaseTransaction.sinter
sintercard()
sintercard(
keys
,options?
):ClusterTransaction
Gets the cardinality of the intersection of all the given sets.
Parameters
keys
The keys of the sets.
options?
(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.
limit?
number
Returns
ClusterTransaction
See
valkey.io for details.
Remarks
Since Valkey version 7.0.0.
Inherited from
BaseTransaction.sintercard
sinterstore()
sinterstore(
destination
,keys
):ClusterTransaction
Stores the members of the intersection of all given sets specified by keys
into a new set at destination
.
Parameters
destination
The key of the destination set.
keys
The keys from which to retrieve the set members.
Command Response - The number of elements in the resulting set.
Returns
ClusterTransaction
See
valkey.io for details.
Inherited from
BaseTransaction.sinterstore
sismember()
sismember(
key
,member
):ClusterTransaction
Returns if member
is a member of the set stored at key
.
Parameters
key
The key of the set.
member
The member to check for existence in the set.
Command Response - true
if the member exists in the set, false
otherwise.
If key
doesn't exist, it is treated as an empty set and the command returns false
.
Returns
ClusterTransaction
See
valkey.io for details.
Inherited from
BaseTransaction.sismember
smembers()
smembers(
key
):ClusterTransaction
Returns all the members of the set value stored at key
.
Parameters
key
The key to return its members.
Command Response - all members of the set.
If key
does not exist, it is treated as an empty set and this command returns empty list.
Returns
ClusterTransaction
See
valkey.io for details.
Inherited from
BaseTransaction.smembers
smismember()
smismember(
key
,members
):ClusterTransaction
Checks whether each member is contained in the members of the set stored at key
.
Parameters
key
The key of the set to check.
members
A list of members to check for existence in the set.
Command Response - An array
of boolean
values, each indicating if the respective member exists in the set.
Returns
ClusterTransaction
See
valkey.io for details.
Remarks
Since Valkey version 6.2.0.
Inherited from
BaseTransaction.smismember
smove()
smove(
source
,destination
,member
):ClusterTransaction
Moves member
from the set at source
to the set at destination
, removing it from the source set.
Creates a new destination set if needed. The operation is atomic.
Parameters
source
The key of the set to remove the element from.
destination
The key of the set to add the element to.
member
The set element to move.
Command Response - true
on success, or false
if the source
set does not exist or the element is not a member of the source set.
Returns
ClusterTransaction
See
valkey.io for more details.
Inherited from
BaseTransaction.smove
sort()
sort(
key
,options?
):ClusterTransaction
Sorts the elements in the list, set, or sorted set at key
and returns the result.
The sort
command can be used to sort elements based on different criteria and
apply transformations on sorted elements.
To store the result into a new key, see sortStore.
Parameters
key
The key of the list, set, or sorted set to be sorted.
options?
(Optional) SortOptions.
Command Response - An Array
of sorted elements.
Returns
ClusterTransaction
See
valkey.io for more details.
Remarks
When in cluster mode, both key
and the patterns specified in SortOptions.byPattern
and SortOptions.getPatterns must map to the same hash slot. The use of SortOptions.byPattern
and SortOptions.getPatterns in cluster mode is supported since Valkey version 8.0.
Inherited from
BaseTransaction.sort
sortReadOnly()
sortReadOnly(
key
,options?
):ClusterTransaction
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
The key of the list, set, or sorted set to be sorted.
options?
(Optional) SortOptions.
Command Response - An Array
of sorted elements
Returns
ClusterTransaction
Remarks
Since Valkey version 7.0.0.
Inherited from
BaseTransaction.sortReadOnly
sortStore()
sortStore(
key
,destination
,options?
):ClusterTransaction
Sorts the elements in the list, set, or sorted set at key
and stores the result in
destination
.
The sort
command can be used to sort elements based on different criteria and
apply transformations on sorted elements, and store the result in a new key.
To get the sort result without storing it into a key, see sort or sortReadOnly.
Parameters
key
The key of the list, set, or sorted set to be sorted.
destination
The key where the sorted result will be stored.
options?
(Optional) SortOptions.
Command Response - The number of elements in the sorted key stored at destination
.
Returns
ClusterTransaction
See
valkey.io for more details.
Remarks
When in cluster mode, key
, destination
and the patterns specified in SortOptions.byPattern
and SortOptions.getPatterns must map to the same hash slot. The use of SortOptions.byPattern
and SortOptions.getPatterns in cluster mode is supported since Valkey version 8.0.
Inherited from
BaseTransaction.sortStore
spop()
spop(
key
):ClusterTransaction
Removes and returns one random member from the set value store at key
.
Parameters
key
The key of the set.
Command Response - the value of the popped member.
If key
does not exist, null will be returned.
Returns
ClusterTransaction
See
valkey.io for details.
To pop multiple members, see spopCount
.
Inherited from
BaseTransaction.spop
spopCount()
spopCount(
key
,count
):ClusterTransaction
Removes and returns up to count
random members from the set value store at key
, depending on the set's length.
Parameters
key
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
ClusterTransaction
See
valkey.io for details.
Inherited from
BaseTransaction.spopCount
srandmember()
srandmember(
key
):ClusterTransaction
Returns a random element from the set value stored at key
.
Parameters
key
The key from which to retrieve the set member.
Command Response - A random element from the set, or null if key
does not exist.
Returns
ClusterTransaction
See
valkey.io for more details.
Inherited from
BaseTransaction.srandmember
srandmemberCount()
srandmemberCount(
key
,count
):ClusterTransaction
Returns one or more random elements from the set value stored at key
.
Parameters
key
The key of the sorted set.
count
number
The number of members to return.
If count
is positive, returns unique members.
If count
is negative, allows for duplicates members.
Command Response - A list of members from the set. If the set does not exist or is empty, an empty list will be returned.
Returns
ClusterTransaction
See
valkey.io for more details.
Inherited from
BaseTransaction.srandmemberCount
srem()
srem(
key
,members
):ClusterTransaction
Removes the specified members from the set stored at key
. Specified members that are not a member of this set are ignored.
Parameters
key
The key to remove the members from its set.
members
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
ClusterTransaction
See
valkey.io for details.
Inherited from
BaseTransaction.srem
sscan()
sscan(
key
,cursor
,options?
):ClusterTransaction
Iterates incrementally over a set.
Parameters
key
The key of the set.
cursor
The cursor that points to the next iteration of results. A value of "0"
indicates the start of the search.
options?
The (Optional) BaseScanOptions.
Command Response - An array of the cursor and the subset of the set held by key
. The first element is always the cursor
and for the next iteration of results.
The cursor
will be "0"
on the last iteration of the set. The second element is always an array of the subset of the set held in key
.
Returns
ClusterTransaction
See
[valkey.io](https://valkey.io/commands/sscan](https://valkey.io/commands/sscan) for details.
Inherited from
BaseTransaction.sscan
strlen()
strlen(
key
):ClusterTransaction
Returns the length of the string value stored at key
.
Parameters
key
The key
to check its length.
Command Response - The length of the string value stored at key
If key
does not exist, it is treated as an empty string, and the command returns 0
.
Returns
ClusterTransaction
See
[https://valkey.io/commands/strlen/) for details.
Inherited from
BaseTransaction.strlen
sunion()
sunion(
keys
):ClusterTransaction
Gets the union of all the given sets.
Parameters
keys
The keys of the sets.
Command Response - A Set
of members which are present in at least one of the given sets.
If none of the sets exist, an empty Set
will be returned.
Returns
ClusterTransaction
See
valkey.io for details.
Inherited from
BaseTransaction.sunion
sunionstore()
sunionstore(
destination
,keys
):ClusterTransaction
Stores the members of the union of all given sets specified by keys
into a new set
at destination
.
Parameters
destination
The key of the destination set.
keys
The keys from which to retrieve the set members.
Command Response - The number of elements in the resulting set.
Returns
ClusterTransaction
See
valkey.io for details.
Inherited from
BaseTransaction.sunionstore
time()
time():
ClusterTransaction
Returns the server time.
Returns
ClusterTransaction
See
valkey.io for details.
Command Response - The current server time as an array
with two items:
- A Unix timestamp,
- The amount of microseconds already elapsed in the current second.
Inherited from
BaseTransaction.time
touch()
touch(
keys
):ClusterTransaction
Updates the last access time of the specified keys.
Parameters
keys
The keys to update the last access time of.
Command Response - The number of keys that were updated. A key is ignored if it doesn't exist.
Returns
ClusterTransaction
See
valkey.io for details.
Inherited from
BaseTransaction.touch
ttl()
ttl(
key
):ClusterTransaction
Returns the remaining time to live of key
that has a timeout.
Parameters
key
The key to return its timeout.
Command Response - TTL in seconds, -2
if key
does not exist or -1
if key
exists but has no associated expire.
Returns
ClusterTransaction
See
valkey.io for details.
Inherited from
BaseTransaction.ttl
type()
type(
key
):ClusterTransaction
Returns the string representation of the type of the value stored at key
.
Parameters
key
The key to check its data type.
Command Response - If the key exists, the type of the stored value is returned. Otherwise, a "none" string is returned.
Returns
ClusterTransaction
See
valkey.io for details.
Inherited from
BaseTransaction.type
unlink()
unlink(
keys
):ClusterTransaction
Removes the specified keys. A key is ignored if it does not exist. This command, similar to del, removes specified keys and ignores non-existent ones. However, this command does not block the server, while `DEL` does.
Parameters
keys
The keys we wanted to unlink.
Command Response - The number of keys that were unlinked.
Returns
ClusterTransaction
See
valkey.io for details.
Inherited from
BaseTransaction.unlink
wait()
wait(
numreplicas
,timeout
):ClusterTransaction
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
ClusterTransaction
See
valkey.io for more details.
Inherited from
BaseTransaction.wait
xack()
xack(
key
,group
,ids
):ClusterTransaction
Returns the number of messages that were successfully acknowledged by the consumer group member of a stream. This command should be called on a pending message so that such message does not get processed again.
Parameters
key
The key of the stream.
group
The consumer group name.
ids
string
[]
An array of entry ids.
Command Response - The number of messages that were successfully acknowledged.
Returns
ClusterTransaction
See
valkey.io for details.
Inherited from
BaseTransaction.xack
xadd()
xadd(
key
,values
,options?
):ClusterTransaction
Adds an entry to the specified stream stored at key
. If the key
doesn't exist, the stream is created.
Parameters
key
The key of the stream.
values
[GlideString
, GlideString
][]
field-value pairs to be added to the entry.
options?
(Optional) Stream add options.
Command Response - The id of the added entry, or null
if options.makeStream
is set to false
and no stream with the matching key
exists.
Returns
ClusterTransaction
See
valkey.io for details.
Inherited from
BaseTransaction.xadd
xautoclaim()
xautoclaim(
key
,group
,consumer
,minIdleTime
,start
,options?
):ClusterTransaction
Transfers ownership of pending stream entries that match the specified criteria.
Parameters
key
The key of the stream.
group
The consumer group name.
consumer
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.
options?
(Optional) Additional parameters:
- (Optional) count
: the number of claimed entries.
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](../../BaseClient/type-aliases/GlideRecord.md).
count?
number
Returns
ClusterTransaction
See
valkey.io for more details.
Remarks
Since Valkey version 6.2.0.
Inherited from
BaseTransaction.xautoclaim
xautoclaimJustId()
xautoclaimJustId(
key
,group
,consumer
,minIdleTime
,start
,options?
):ClusterTransaction
Transfers ownership of pending stream entries that match the specified criteria.
Parameters
key
The key of the stream.
group
The consumer group name.
consumer
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.
options?
(Optional) Additional parameters:
- (Optional) count
: limits the number of claimed entries to the specified value.
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.
count?
number
Returns
ClusterTransaction
See
valkey.io for more details.
Remarks
Since Valkey version 6.2.0.
Inherited from
BaseTransaction.xautoclaimJustId
xclaim()
xclaim(
key
,group
,consumer
,minIdleTime
,ids
,options?
):ClusterTransaction
Changes the ownership of a pending message.
Parameters
key
The key of the stream.
group
The consumer group name.
consumer
The group consumer.
minIdleTime
number
The minimum idle time for the message to be claimed.
ids
string
[]
An array of entry ids.
options?
(Optional) Stream claim options StreamClaimOptions.
Command Response - Message entries that are claimed by the consumer.
The response comes in format GlideRecord<[GlideString, GlideString][]>
, see GlideRecord.
Returns
ClusterTransaction
See
valkey.io for details.
Inherited from
BaseTransaction.xclaim
xclaimJustId()
xclaimJustId(
key
,group
,consumer
,minIdleTime
,ids
,options?
):ClusterTransaction
Changes the ownership of a pending message. This function returns an array
with
only the message/entry IDs, and is equivalent to using JUSTID
in the Valkey API.
Parameters
key
The key of the stream.
group
The consumer group name.
consumer
The group consumer.
minIdleTime
number
The minimum idle time for the message to be claimed.
ids
string
[]
An array of entry ids.
options?
(Optional) Stream claim options StreamClaimOptions.
Command Response - An array
of message ids claimed by the consumer.
Returns
ClusterTransaction
See
valkey.io for details.
Inherited from
BaseTransaction.xclaimJustId
xdel()
xdel(
key
,ids
):ClusterTransaction
Removes the specified entries by id from a stream, and returns the number of entries deleted.
Parameters
key
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
ClusterTransaction
See
valkey.io for more details.
Inherited from
BaseTransaction.xdel
xgroupCreate()
xgroupCreate(
key
,groupName
,id
,options?
):ClusterTransaction
Creates a new consumer group uniquely identified by groupname
for the stream
stored at key
.
Parameters
key
The key of the stream.
groupName
The newly created consumer group name.
id
string
Stream entry ID that specifies the last delivered entry in the stream from the new
group’s perspective. The special ID "$"
can be used to specify the last entry in the stream.
Command Response - "OK"
.
options?
Returns
ClusterTransaction
See
valkey.io for details.
Inherited from
BaseTransaction.xgroupCreate
xgroupCreateConsumer()
xgroupCreateConsumer(
key
,groupName
,consumerName
):ClusterTransaction
Creates a consumer named consumerName
in the consumer group groupName
for the stream stored at key
.
Parameters
key
The key of the stream.
groupName
The consumer group name.
consumerName
The newly created consumer.
Command Response - true
if the consumer is created. Otherwise, returns false
.
Returns
ClusterTransaction
See
valkey.io for more details.
Inherited from
BaseTransaction.xgroupCreateConsumer
xgroupDelConsumer()
xgroupDelConsumer(
key
,groupName
,consumerName
):ClusterTransaction
Deletes a consumer named consumerName
in the consumer group groupName
for the stream stored at key
.
Parameters
key
The key of the stream.
groupName
The consumer group name.
consumerName
The consumer to delete.
Command Response - The number of pending messages the consumer
had before it was deleted.
Returns
ClusterTransaction
See
valkey.io for more details.
Inherited from
BaseTransaction.xgroupDelConsumer
xgroupDestroy()
xgroupDestroy(
key
,groupName
):ClusterTransaction
Destroys the consumer group groupname
for the stream stored at key
.
Parameters
key
The key of the stream.
groupName
Returns
ClusterTransaction
See
valkey.io for details.
Inherited from
BaseTransaction.xgroupDestroy
xgroupSetId()
xgroupSetId(
key
,groupName
,id
,options?
):ClusterTransaction
Sets the last delivered ID for a consumer group.
Parameters
key
The key of the stream.
groupName
The consumer group name.
id
string
The stream entry ID that should be set as the last delivered ID for the consumer group.
options?
(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"
.
entriesRead?
number
Returns
ClusterTransaction
See
valkey.io for more details.
Inherited from
BaseTransaction.xgroupSetId
xinfoConsumers()
xinfoConsumers(
key
,group
):ClusterTransaction
Returns the list of all consumers and their attributes for the given consumer group of the
stream stored at key
.
Parameters
key
group
Returns
ClusterTransaction
See
valkey.io for details.
Command Response - An Array
of Records
, where each mapping contains the attributes
of a consumer for the given consumer group of the stream at key
.
The response comes in format GlideRecord<GlideString | number>[]
, see GlideRecord.
Inherited from
BaseTransaction.xinfoConsumers
xinfoGroups()
xinfoGroups(
key
):ClusterTransaction
Returns the list of all consumer groups and their attributes for the stream stored at key
.
Parameters
key
The key of the stream.
Command Response - An Array
of Records
, where each mapping represents the
attributes of a consumer group for the stream at key
.
The response comes in format GlideRecord<GlideString | number | null>[]
, see GlideRecord.
Returns
ClusterTransaction
See
valkey.io for details.
Inherited from
BaseTransaction.xinfoGroups
xinfoStream()
xinfoStream(
key
,fullOptions?
):ClusterTransaction
Returns information about the stream stored at key
.
Parameters
key
The key of the stream.
fullOptions?
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.
number
| boolean
Returns
ClusterTransaction
Inherited from
BaseTransaction.xinfoStream
xlen()
xlen(
key
):ClusterTransaction
Returns the number of entries in the stream stored at key
.
Parameters
key
The key of the stream.
Command Response - The number of entries in the stream. If key
does not exist, returns 0
.
Returns
ClusterTransaction
See
valkey.io for details.
Inherited from
BaseTransaction.xlen
xpending()
xpending(
key
,group
):ClusterTransaction
Returns stream message summary information for pending messages matching a given range of IDs.
Parameters
key
The key of the stream.
group
The consumer group name.
Command Response - An array
that includes the summary of the pending messages.
See example of xpending for more details.
Returns
ClusterTransaction
See
valkey.io for details.
Inherited from
BaseTransaction.xpending
xpendingWithOptions()
xpendingWithOptions(
key
,group
,options
):ClusterTransaction
Returns stream message summary information for pending messages matching a given range of IDs.
Parameters
key
The key of the stream.
group
The consumer group name.
options
Additional options to filter entries, see StreamPendingOptions.
Command Response - A 2D-array
of 4-tuples containing extended message information.
See example of xpendingWithOptions for more details.
Returns
ClusterTransaction
See
valkey.io for details.
Inherited from
BaseTransaction.xpendingWithOptions
xrange()
xrange(
key
,start
,end
,count?
):ClusterTransaction
Returns stream entries matching a given range of entry IDs.
Parameters
key
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.
count?
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
ClusterTransaction
See
valkey.io for more details.
Inherited from
BaseTransaction.xrange
xread()
xread(
keys_and_ids
,options?
):ClusterTransaction
Reads entries from the given streams.
Parameters
keys_and_ids
An object of stream keys and entry IDs to read from.
Record
\<string
, string
> | GlideRecord
\<string
>
options?
(Optional) Parameters detailing how to read the stream - see StreamReadOptions.
Command Response - A list of stream keys with a Record
of stream IDs mapped to an Array
of entries or null
if key does not exist.
The response comes in format GlideRecord<GlideRecord<[GlideString, GlideString][]>>
, see GlideRecord.
Returns
ClusterTransaction
See
valkey.io for details.
Inherited from
BaseTransaction.xread
xreadgroup()
xreadgroup(
group
,consumer
,keys_and_ids
,options?
):ClusterTransaction
Reads entries from the given streams owned by a consumer group.
Parameters
group
The consumer group name.
consumer
The group consumer.
keys_and_ids
An object of stream keys and entry IDs to read from.
Use the special ID of ">"
to receive only new messages.
Record
\<string
, string
> | GlideRecord
\<string
>
options?
(Optional) Parameters detailing how to read the stream - see StreamReadGroupOptions.
Command Response - A list of stream keys with a Record
of stream IDs mapped to an Array
of entries.
Returns null
if there is no stream that can be served.
The response comes in format GlideRecord<GlideRecord<[GlideString, GlideString][]>>
, see GlideRecord.
Returns
ClusterTransaction
See
valkey.io for details.
Inherited from
BaseTransaction.xreadgroup
xrevrange()
xrevrange(
key
,end
,start
,count?
):ClusterTransaction
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
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.
count?
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
ClusterTransaction
See
valkey.io for more details.
Inherited from
BaseTransaction.xrevrange
xtrim()
xtrim(
key
,options
):ClusterTransaction
Trims the stream stored at key
by evicting older entries.
Parameters
key
the key of the stream
options
options detailing how to trim the stream.
Command Response - The number of entries deleted from the stream. If key
doesn't exist, 0 is returned.
Returns
ClusterTransaction
See
valkey.io for details.
Inherited from
BaseTransaction.xtrim
zadd()
zadd(
key
,membersAndScores
,options?
):ClusterTransaction
Adds members with their scores to the sorted set stored at key
.
If a member is already a part of the sorted set, its score is updated.
Parameters
key
The key of the sorted set.
membersAndScores
A list of members and their corresponding scores or a mapping of members to their corresponding scores.
Record
\<string
, Score
> | ElementAndScore
[]
options?
(Optional) The ZADD
options - see ZAddOptions.
Command Response - The number of elements added to the sorted set.
If ZAddOptions.changed is set to true
, returns the number of elements updated in the sorted set.
Returns
ClusterTransaction
See
valkey.io for details.
Inherited from
BaseTransaction.zadd
zaddIncr()
zaddIncr(
key
,member
,increment
,options?
):ClusterTransaction
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
The key of the sorted set.
member
A member in the sorted set to increment.
increment
number
The score to increment the member.
options?
(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
ClusterTransaction
See
valkey.io for details.
Inherited from
BaseTransaction.zaddIncr
zcard()
zcard(
key
):ClusterTransaction
Returns the cardinality (number of elements) of the sorted set stored at key
.
Parameters
key
The key of the sorted set.
Command Response - The number of elements in the sorted set.
If key
does not exist, it is treated as an empty sorted set, and this command returns 0
.
Returns
ClusterTransaction
See
valkey.io for details.
Inherited from
BaseTransaction.zcard
zcount()
zcount(
key
,minScore
,maxScore
):ClusterTransaction
Returns the number of members in the sorted set stored at key
with scores between minScore
and maxScore
.
Parameters
key
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
ClusterTransaction
See
valkey.io for details.
Inherited from
BaseTransaction.zcount
zdiff()
zdiff(
keys
):ClusterTransaction
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
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
ClusterTransaction
See
valkey.io for details.
Remarks
Since Valkey version 6.2.0.
Inherited from
BaseTransaction.zdiff
zdiffstore()
zdiffstore(
destination
,keys
):ClusterTransaction
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
The key for the resulting sorted set.
keys
The keys of the sorted sets to compare.
Command Response - The number of members in the resulting sorted set stored at destination
.
Returns
ClusterTransaction
See
valkey.io for details.
Remarks
Since Valkey version 6.2.0.
Inherited from
BaseTransaction.zdiffstore
zdiffWithScores()
zdiffWithScores(
keys
):ClusterTransaction
Returns the difference between the first sorted set and all the successive sorted sets, with the associated scores.
Parameters
keys
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
ClusterTransaction
See
valkey.io for details.
Remarks
Since Valkey version 6.2.0.
Inherited from
BaseTransaction.zdiffWithScores
zincrby()
zincrby(
key
,increment
,member
):ClusterTransaction
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.
If key
does not exist, a new sorted set is created with the specified member as its sole member.
Parameters
key
The key of the sorted set.
increment
number
The score increment.
member
A member of the sorted set.
Command Response - The new score of member
.
Returns
ClusterTransaction
See
valkey.io for details.
Inherited from
BaseTransaction.zincrby
zinter()
zinter(
keys
):ClusterTransaction
Computes the intersection of sorted sets given by the specified keys
and returns a list of intersecting elements.
To get the scores as well, see zinterWithScores.
To store the result in a key as a sorted set, see zinterStore.
Parameters
keys
The keys of the sorted sets.
Command Response - The resulting array of intersecting elements.
Returns
ClusterTransaction
Remarks
Since Valkey version 6.2.0.
See
valkey.io for details.
Inherited from
BaseTransaction.zinter
zintercard()
zintercard(
keys
,options?
):ClusterTransaction
Returns the cardinality of the intersection of the sorted sets specified by keys
.
Parameters
keys
The keys of the sorted sets to intersect.
options?
(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.
limit?
number
Returns
ClusterTransaction
See
valkey.io for details.
Remarks
Since Valkey version 7.0.0.
Inherited from
BaseTransaction.zintercard
zinterstore()
zinterstore(
destination
,keys
,options?
):ClusterTransaction
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
The key of the destination sorted set.
keys
The keys of the sorted sets with possible formats:
- GlideString[]
- for keys only.
- KeyWeight[]
- for weighted keys with score multipliers.
GlideString
[] | KeyWeight
[]
options?
(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
.
aggregationType?
Returns
ClusterTransaction
See
valkey.io for details.
Remarks
Since Valkey version 6.2.0.
Inherited from
BaseTransaction.zinterstore
zinterWithScores()
zinterWithScores(
keys
,options?
):ClusterTransaction
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
The keys of the sorted sets with possible formats:
- GlideString[]
- for keys only.
- KeyWeight[]
- for weighted keys with score multipliers.
GlideString
[] | KeyWeight
[]
options?
(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.
aggregationType?
Returns
ClusterTransaction
See
valkey.io for details.
Remarks
Since Valkey version 6.2.0.
Inherited from
BaseTransaction.zinterWithScores
zlexcount()
zlexcount(
key
,minLex
,maxLex
):ClusterTransaction
Returns the number of members in the sorted set stored at 'key' with scores between 'minLex' and 'maxLex'.
Parameters
key
The key of the sorted set.
minLex
The minimum lex to count from. Can be negative infinity, or a specific lex and inclusivity.
maxLex
The maximum lex to count up to. Can be positive infinity, or a specific lex and inclusivity.
Command Response - The number of members in the specified lex range. If 'key' does not exist, it is treated as an empty sorted set, and the command returns '0'. If maxLex is less than minLex, '0' is returned.
Returns
ClusterTransaction
See
valkey.io for details.
Inherited from
BaseTransaction.zlexcount
zmpop()
zmpop(
keys
,modifier
,count?
):ClusterTransaction
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
The keys of the sorted sets.
modifier
The element pop criteria - either ScoreFilter.MIN or ScoreFilter.MAX to pop the member with the lowest/highest score accordingly.
count?
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
ClusterTransaction
See
valkey.io for details.
Remarks
Since Valkey version 7.0.0.
Inherited from
BaseTransaction.zmpop
zmscore()
zmscore(
key
,members
):ClusterTransaction
Returns the scores associated with the specified members
in the sorted set stored at key
.
Parameters
key
The key of the sorted set.
members
A list of members in the sorted set.
Command Response - An array
of scores corresponding to members
.
If a member does not exist in the sorted set, the corresponding value in the list will be null
.
Returns
ClusterTransaction
See
valkey.io for details.
Remarks
Since Valkey version 6.2.0.
Inherited from
BaseTransaction.zmscore
zpopmax()
zpopmax(
key
,count?
):ClusterTransaction
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
The key of the sorted set.
count?
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
ClusterTransaction
See
valkey.io for more details.
Inherited from
BaseTransaction.zpopmax
zpopmin()
zpopmin(
key
,count?
):ClusterTransaction
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
The key of the sorted set.
count?
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
ClusterTransaction
See
valkey.io for more details.
Inherited from
BaseTransaction.zpopmin
zrandmember()
zrandmember(
key
):ClusterTransaction
Returns a random member from the sorted set stored at key
.
Parameters
key
Returns
ClusterTransaction
See
valkey.io for details.
Inherited from
BaseTransaction.zrandmember
zrandmemberWithCount()
zrandmemberWithCount(
key
,count
):ClusterTransaction
Returns random members from the sorted set stored at key
.
Parameters
key
count
number
The number of members to return.
If count
is positive, returns unique members.
If negative, allows for duplicates.
Command Response - An array
of members from the sorted set.
If the sorted set does not exist or is empty, the response will be an empty array
.
Returns
ClusterTransaction
See
valkey.io for details.
Inherited from
BaseTransaction.zrandmemberWithCount
zrandmemberWithCountWithScores()
zrandmemberWithCountWithScores(
key
,count
):ClusterTransaction
Returns random members with scores from the sorted set stored at key
.
Parameters
key
count
number
The number of members to return.
If count
is positive, returns unique members.
If negative, allows for duplicates.
Command Response - A list of KeyWeight tuples, which store member names and their respective scores.
If the sorted set does not exist or is empty, the response will be an empty array
.
Returns
ClusterTransaction
See
valkey.io for details.
Inherited from
BaseTransaction.zrandmemberWithCountWithScores
zrange()
zrange(
key
,rangeQuery
,reverse
):ClusterTransaction
Returns the specified range of elements in the sorted set stored at key
.
ZRANGE
can perform different types of range queries: by index (rank), by the score, or by lexicographical order.
To get the elements with their scores, see zrangeWithScores.
Parameters
key
The key of the sorted set.
rangeQuery
The range query object representing the type of range query to perform. - For range queries by index (rank), use RangeByIndex. - For range queries by lexicographical order, use RangeByLex. - For range queries by score, use RangeByScore.
RangeByScore
| RangeByLex
| RangeByIndex
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 within the specified range.
If key
does not exist, it is treated as an empty sorted set, and the command returns an empty array.
Returns
ClusterTransaction
See
valkey.io for details.
Inherited from
BaseTransaction.zrange
zrangeStore()
zrangeStore(
destination
,source
,rangeQuery
,reverse
):ClusterTransaction
Stores a specified range of elements from the sorted set at source
, into a new
sorted set at destination
. If destination
doesn't exist, a new sorted
set is created; if it exists, it's overwritten.
Parameters
destination
The key for the destination sorted set.
source
The key of the source sorted set.
rangeQuery
The range query object representing the type of range query to perform. - For range queries by index (rank), use RangeByIndex. - For range queries by lexicographical order, use RangeByLex. - For range queries by score, use RangeByScore.
RangeByScore
| RangeByLex
| RangeByIndex
reverse
boolean
= false
If true
, reverses the sorted set, with index 0
as the element with the highest score.
Command Response - The number of elements in the resulting sorted set.
Returns
ClusterTransaction
See
valkey.io for details.
Remarks
Since Valkey version 6.2.0.
Inherited from
BaseTransaction.zrangeStore
zrangeWithScores()
zrangeWithScores(
key
,rangeQuery
,reverse
):ClusterTransaction
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
The key of the sorted set.
rangeQuery
The range query object representing the type of range query to perform. - For range queries by index (rank), use RangeByIndex. - For range queries by score, use RangeByScore.
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
ClusterTransaction
See
valkey.io for details.
Inherited from
BaseTransaction.zrangeWithScores
zrank()
zrank(
key
,member
):ClusterTransaction
Returns the rank of member
in the sorted set stored at key
, with scores ordered from low to high.
To get the rank of member
with its score, see zrankWithScore.
Parameters
key
The key of the sorted set.
member
The member whose rank is to be retrieved.
Command Response - The rank of member
in the sorted set.
If key
doesn't exist, or if member
is not present in the set, null will be returned.
Returns
ClusterTransaction
See
valkey.io for more details.
Inherited from
BaseTransaction.zrank
zrankWithScore()
zrankWithScore(
key
,member
):ClusterTransaction
Returns the rank of member
in the sorted set stored at key
with its score, where scores are ordered from the lowest to highest.
Parameters
key
The key of the sorted set.
member
The member whose rank is to be retrieved.
Command Response - A list containing the rank and score of member
in the sorted set.
If key
doesn't exist, or if member
is not present in the set, null will be returned.
Returns
ClusterTransaction
See
valkey.io for more details.
Remarks
Since Valkey version 7.2.0.
Inherited from
BaseTransaction.zrankWithScore
zrem()
zrem(
key
,members
):ClusterTransaction
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
The key of the sorted set.
members
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
ClusterTransaction
See
valkey.io for details.
Inherited from
BaseTransaction.zrem
zremRangeByLex()
zremRangeByLex(
key
,minLex
,maxLex
):ClusterTransaction
Removes all elements in the sorted set stored at key
with lexicographical order between minLex
and maxLex
.
Parameters
key
The key of the sorted set.
minLex
The minimum lex to count from. Can be negative infinity, or a specific lex and inclusivity.
maxLex
The maximum lex to count up to. Can be positive infinity, or a specific lex 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 minLex
is greater than maxLex
, 0 is returned.
Returns
ClusterTransaction
See
valkey.io for details.
Inherited from
BaseTransaction.zremRangeByLex
zremRangeByRank()
zremRangeByRank(
key
,start
,end
):ClusterTransaction
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
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
ClusterTransaction
See
valkey.io for details.
Inherited from
BaseTransaction.zremRangeByRank
zremRangeByScore()
zremRangeByScore(
key
,minScore
,maxScore
):ClusterTransaction
Removes all elements in the sorted set stored at key
with a score between minScore
and maxScore
.
Parameters
key
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
ClusterTransaction
See
valkey.io for details.
Inherited from
BaseTransaction.zremRangeByScore
zrevrank()
zrevrank(
key
,member
):ClusterTransaction
Returns the rank of member
in the sorted set stored at key
, where
scores are ordered from the highest to lowest, starting from 0
.
To get the rank of member
with its score, see zrevrankWithScore.
Parameters
key
The key of the sorted set.
member
The member whose rank is to be retrieved.
Command Response - The rank 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
ClusterTransaction
See
valkey.io for details.
Inherited from
BaseTransaction.zrevrank
zrevrankWithScore()
zrevrankWithScore(
key
,member
):ClusterTransaction
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
The key of the sorted set.
member
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
ClusterTransaction
See
valkey.io for details.
Remarks
Since Valkey version 7.2.0.
Inherited from
BaseTransaction.zrevrankWithScore
zscan()
zscan(
key
,cursor
,options?
):ClusterTransaction
Iterates incrementally over a sorted set.
Parameters
key
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.
options?
(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
ClusterTransaction
See
valkey.io for more details.
Inherited from
BaseTransaction.zscan
zscore()
zscore(
key
,member
):ClusterTransaction
Returns the score of member
in the sorted set stored at key
.
Parameters
key
The key of the sorted set.
member
The member whose score is to be retrieved.
Command Response - The score of the member.
If member
does not exist in the sorted set, null is returned.
If key
does not exist, null is returned.
Returns
ClusterTransaction
See
valkey.io for details.
Inherited from
BaseTransaction.zscore
zunion()
zunion(
keys
):ClusterTransaction
Computes the union of sorted sets given by the specified keys
and returns a list of union elements.
To get the scores as well, see zunionWithScores. To store the result in a key as a sorted set, see zunionstore.
Parameters
keys
The keys of the sorted sets.
Command Response - The resulting array with a union of sorted set elements.
Returns
ClusterTransaction
See
valkey.io for details.
Remarks
Since Valkey version 6.2.0.
Inherited from
BaseTransaction.zunion
zunionstore()
zunionstore(
destination
,keys
,options?
):ClusterTransaction
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
The key of the destination sorted set.
keys
The keys of the sorted sets with possible formats:
- GlideString[]
- for keys only.
- KeyWeight[]
- for weighted keys with their score multipliers.
GlideString
[] | KeyWeight
[]
options?
(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
.
aggregationType?
Returns
ClusterTransaction
See
valkey.io for details.
Inherited from
BaseTransaction.zunionstore
zunionWithScores()
zunionWithScores(
keys
,options?
):ClusterTransaction
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
The keys of the sorted sets with possible formats:
- GlideString[]
- for keys only.
- KeyWeight[]
- for weighted keys with their score multipliers.
GlideString
[] | KeyWeight
[]
options?
(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.
aggregationType?
Returns
ClusterTransaction
See
valkey.io for details.
Remarks
Since Valkey version 6.2.0.
Inherited from
BaseTransaction.zunionWithScores