Package glide.api.models
Class BaseBatch<T extends BaseBatch<T>>
- java.lang.Object
-
- glide.api.models.BaseBatch<T>
-
- Type Parameters:
T- child typing for chaining method calls.
- Direct Known Subclasses:
Batch,ClusterBatch
public abstract class BaseBatch<T extends BaseBatch<T>> extends java.lang.ObjectBase class encompassing shared commands for both standalone and cluster server installations. Batches allow the execution of a group of commands in a single step.Batch Response: An
arrayof command responses is returned by the clientexeccommand, in the order they were given. Each element in the array represents a command given to the batch. The response for each command depends on the executed Valkey command. Specific response types are documented alongside each method.isAtomic: Determines whether the batch is atomic or non-atomic. If
true, the batch will be executed as an atomic transaction. Iffalse, the batch will be executed as a non-atomic pipeline.
-
-
Field Summary
Fields Modifier and Type Field Description protected booleanbinaryOutputFlag whether batch commands may return binary data.
If set totrue, all commands in this batch returnGlideStringinstead ofString.protected CommandRequestOuterClass.Batch.BuilderprotobufBatchCommand class to send a single request to Valkey.
-
Constructor Summary
Constructors Modifier Constructor Description protectedBaseBatch(boolean isAtomic)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description <ArgType> Tappend(ArgType key, ArgType value)Appends avalueto akey.<ArgType> Tbitcount(ArgType key)Counts the number of set bits (population counting) in a string stored atkey.<ArgType> Tbitcount(ArgType key, long start)Counts the number of set bits (population counting) in a string stored atkey.<ArgType> Tbitcount(ArgType key, long start, long end)Counts the number of set bits (population counting) in a string stored atkey.<ArgType> Tbitcount(ArgType key, long start, long end, @NonNull BitmapIndexType options)Counts the number of set bits (population counting) in a string stored atkey.<ArgType> Tbitfield(ArgType key, @NonNull BitFieldOptions.BitFieldSubCommands[] subCommands)Reads or modifies the array of bits representing the string that is held atkeybased on the specifiedsubCommands.<ArgType> TbitfieldReadOnly(ArgType key, @NonNull BitFieldOptions.BitFieldReadOnlySubCommands[] subCommands)Reads the array of bits representing the string that is held atkeybased on the specifiedsubCommands.
This command is routed depending on the client'sReadFromstrategy.<ArgType> Tbitop(@NonNull BitwiseOperation bitwiseOperation, ArgType destination, @NonNull ArgType[] keys)Perform a bitwise operation between multiple keys (containing string values) and store the result in thedestination.<ArgType> Tbitpos(ArgType key, long bit)Returns the position of the first bit matching the givenbitvalue.<ArgType> Tbitpos(ArgType key, long bit, long start)Returns the position of the first bit matching the givenbitvalue.<ArgType> Tbitpos(ArgType key, long bit, long start, long end)Returns the position of the first bit matching the givenbitvalue.<ArgType> Tbitpos(ArgType key, long bit, long start, long end, @NonNull BitmapIndexType offsetType)Returns the position of the first bit matching the givenbitvalue.<ArgType> Tblmove(ArgType source, ArgType destination, @NonNull ListDirection whereFrom, @NonNull ListDirection whereTo, double timeout)Blocks the connection until it atomically pops and removes the left/right-most element to the list stored atsourcedepending onwhereFrom, and pushes the element at the first/last element of the list stored atdestinationdepending onwhereFrom.
BLMoveis the blocking variant of#lmove(ArgType, ArgType, ListDirection, ListDirection).<ArgType> Tblmpop(@NonNull ArgType[] keys, @NonNull ListDirection direction, double timeout)Blocks the connection until it pops one element from the first non-empty list from the providedkeys.<ArgType> Tblmpop(@NonNull ArgType[] keys, @NonNull ListDirection direction, @NonNull java.lang.Long count, double timeout)Blocks the connection until it pops one or more elements from the first non-empty list from the providedkeys.<ArgType> Tblpop(@NonNull ArgType[] keys, double timeout)Pops an element from the head of the first list that is non-empty, with the givenkeysbeing checked in the order that they are given.
Blocks the connection when there are no elements to pop from any of the given lists.<ArgType> Tbrpop(@NonNull ArgType[] keys, double timeout)Pops an element from the tail of the first list that is non-empty, with the givenkeysbeing checked in the order that they are given.
Blocks the connection when there are no elements to pop from any of the given lists.protected CommandRequestOuterClass.CommandbuildCommand(CommandRequestOuterClass.RequestType requestType)Build protobufCommandRequestOuterClass.Commandobject for given command and arguments.protected CommandRequestOuterClass.CommandbuildCommand(CommandRequestOuterClass.RequestType requestType, CommandRequestOuterClass.Command.ArgsArray args)Build protobufCommandRequestOuterClass.Commandobject for given command and arguments.protected CommandRequestOuterClass.CommandbuildCommand(CommandRequestOuterClass.RequestType requestType, ArgsBuilder argsBuilder)Build protobufCommandRequestOuterClass.Commandobject for given command and arguments.<ArgType> Tbzmpop(@NonNull ArgType[] keys, @NonNull ScoreFilter modifier, double timeout)Blocks the connection until it pops and returns a member-score pair from the first non-empty sorted set, with the givenkeysbeing checked in the order they are provided.
BZMPOPis the blocking variant of#zmpop(ArgType[], ScoreFilter).<ArgType> Tbzmpop(@NonNull ArgType[] keys, @NonNull ScoreFilter modifier, double timeout, long count)Blocks the connection until it pops and returns multiple member-score pairs from the first non-empty sorted set, with the givenkeysbeing checked in the order they are provided.
BZMPOPis the blocking variant of#zmpop(ArgType[], ScoreFilter, long).<ArgType> Tbzpopmax(@NonNull ArgType[] keys, double timeout)Blocks the connection until it removes and returns a member with the highest score from the sorted sets stored at the specifiedkeys.<ArgType> Tbzpopmin(@NonNull ArgType[] keys, double timeout)Blocks the connection until it removes and returns a member with the lowest score from the sorted sets stored at the specifiedkeys.TclientGetName()Gets the name of the current connection.TclientId()Gets the current connection id.TclientPause(long timeout)Suspends all clients for the specified timeout.TclientPause(long timeout, @NonNull ClientPauseMode mode)Suspends all clients for the specified timeout.TclientUnpause()Resumes processing commands on all clients.<ArgType> TconfigGet(@NonNull ArgType[] parameters)Reads the configuration parameters of the running server.
Starting from server version 7, command supports multiple parameters.TconfigResetStat()Resets the statistics reported by the server using the INFO and LATENCY HISTOGRAM commands.TconfigRewrite()Rewrites the configuration file with the current configuration.<ArgType> TconfigSet(@NonNull java.util.Map<ArgType,ArgType> parameters)Sets configuration parameters to the specified values.
Starting from server version 7, command supports multiple parameters.<ArgType> Tcopy(ArgType source, ArgType destination)Copies the value stored at thesourceto thedestinationkey if thedestinationkey does not yet exist.<ArgType> Tcopy(ArgType source, ArgType destination, boolean replace)Copies the value stored at thesourceto thedestinationkey.<ArgType> Tcopy(ArgType source, ArgType destination, long destinationDB)Copies the value stored at thesourceto thedestinationkey ondestinationDB.<ArgType> Tcopy(ArgType source, ArgType destination, long destinationDB, boolean replace)Copies the value stored at thesourceto thedestinationkey ondestinationDB.protected <ArgType> ArgType[]createArray(ArgType... args)Helper function for creating generic type ("ArgType") array<ArgType> TcustomCommand(ArgType[] args)Executes a single command, without checking inputs.Tdbsize()Returns the number of keys in the currently selected database.<ArgType> Tdecr(ArgType key)Decrements the number stored atkeyby one.<ArgType> TdecrBy(ArgType key, long amount)Decrements the number stored atkeybyamount.<ArgType> Tdel(@NonNull ArgType[] keys)Removes the specifiedkeysfrom the database.<ArgType> Tdump(ArgType key)Serialize the value stored atkeyin a Valkey-specific format and return it to the user.<ArgType> Techo(ArgType message)Echoes the providedmessageback.protected CommandRequestOuterClass.Command.ArgsArrayemptyArgs()Build protobufCommandRequestOuterClass.Command.ArgsArrayobject for empty arguments.<ArgType> Texists(@NonNull ArgType[] keys)Returns the number of keys inkeysthat exist in the database.<ArgType> Texpire(ArgType key, long seconds)Sets a timeout onkeyin seconds.<ArgType> Texpire(ArgType key, long seconds, @NonNull ExpireOptions expireOptions)Sets a timeout onkeyin seconds.<ArgType> TexpireAt(ArgType key, long unixSeconds)Sets a timeout onkey.<ArgType> TexpireAt(ArgType key, long unixSeconds, @NonNull ExpireOptions expireOptions)Sets a timeout onkey.<ArgType> Texpiretime(ArgType key)Returns the absolute Unix timestamp (since January 1, 1970) at which the givenkeywill expire, in seconds.
To get the expiration with millisecond precision, use#pexpiretime(ArgType).<ArgType> Tfcall(ArgType function, @NonNull ArgType[] arguments)Invokes a previously loaded read-only function.<ArgType> Tfcall(ArgType function, @NonNull ArgType[] keys, @NonNull ArgType[] arguments)Invokes a previously loaded function.<ArgType> TfcallReadOnly(ArgType function, @NonNull ArgType[] arguments)Invokes a previously loaded function.<ArgType> TfcallReadOnly(ArgType function, @NonNull ArgType[] keys, @NonNull ArgType[] arguments)Invokes a previously loaded read-only function.Tflushall()Deletes all the keys of all the existing databases.Tflushall(FlushMode mode)Deletes all the keys of all the existing databases.Tflushdb()Deletes all the keys of the currently selected database.Tflushdb(FlushMode mode)Deletes all the keys of the currently selected database.<ArgType> TfunctionDelete(ArgType libName)Deletes a library and all its functions.TfunctionDump()Returns the serialized payload of all loaded libraries.TfunctionFlush()Deletes all function libraries.TfunctionFlush(@NonNull FlushMode mode)Deletes all function libraries.TfunctionList(boolean withCode)Returns information about the functions and libraries.<ArgType> TfunctionList(ArgType libNamePattern, boolean withCode)Returns information about the functions and libraries.<ArgType> TfunctionLoad(ArgType libraryCode, boolean replace)Loads a library to Valkey.TfunctionRestore(@lombok.NonNull byte[] payload)Restores libraries from the serialized payload returned byfunctionDump().TfunctionRestore(@lombok.NonNull byte[] payload, @NonNull FunctionRestorePolicy policy)Restores libraries from the serialized payload returned byfunctionDump().TfunctionStats()Returns information about the function that's currently running and information about the available execution engines.<ArgType> Tgeoadd(ArgType key, @NonNull java.util.Map<ArgType,GeospatialData> membersToGeospatialData)Adds geospatial members with their positions to the specified sorted set stored atkey.
If a member is already a part of the sorted set, its position is updated.
To perform ageoaddoperation while specifying optional parameters, use#geoadd(ArgType, Map, GeoAddOptions).<ArgType> Tgeoadd(ArgType key, @NonNull java.util.Map<ArgType,GeospatialData> membersToGeospatialData, @NonNull GeoAddOptions options)Adds geospatial members with their positions to the specified sorted set stored atkey.
If a member is already a part of the sorted set, its position is updated.<ArgType> Tgeodist(ArgType key, ArgType member1, ArgType member2)Returns the distance betweenmember1andmember2saved in the geospatial index stored atkey.<ArgType> Tgeodist(ArgType key, ArgType member1, ArgType member2, @NonNull GeoUnit geoUnit)Returns the distance betweenmember1andmember2saved in the geospatial index stored atkey.<ArgType> Tgeohash(ArgType key, @NonNull ArgType[] members)Returns theGeoHashstrings representing the positions of all the specifiedmembersin the sorted set stored atkey.<ArgType> Tgeopos(ArgType key, @NonNull ArgType[] members)Returns the positions (longitude,latitude) of all the specifiedmembersof the geospatial index represented by the sorted set atkey.<ArgType> Tgeosearch(ArgType key, @NonNull GeoSearchOrigin.SearchOrigin searchFrom, @NonNull GeoSearchShape searchBy)Returns the members of a sorted set populated with geospatial information using#geoadd(ArgType, Map), which are within the borders of the area specified by a given shape.<ArgType> Tgeosearch(ArgType key, @NonNull GeoSearchOrigin.SearchOrigin searchFrom, @NonNull GeoSearchShape searchBy, @NonNull GeoSearchOptions options)Returns the members of a sorted set populated with geospatial information using#geoadd(ArgType, Map), which are within the borders of the area specified by a given shape.<ArgType> Tgeosearch(ArgType key, @NonNull GeoSearchOrigin.SearchOrigin searchFrom, @NonNull GeoSearchShape searchBy, @NonNull GeoSearchOptions options, @NonNull GeoSearchResultOptions resultOptions)Returns the members of a sorted set populated with geospatial information using#geoadd(ArgType, Map), which are within the borders of the area specified by a given shape.<ArgType> Tgeosearch(ArgType key, @NonNull GeoSearchOrigin.SearchOrigin searchFrom, @NonNull GeoSearchShape searchBy, @NonNull GeoSearchResultOptions resultOptions)Returns the members of a sorted set populated with geospatial information using#geoadd(ArgType, Map), which are within the borders of the area specified by a given shape.<ArgType> Tgeosearchstore(ArgType destination, ArgType source, @NonNull GeoSearchOrigin.SearchOrigin searchFrom, @NonNull GeoSearchShape searchBy)Searches for members in a sorted set stored atsourcerepresenting geospatial data within a circular or rectangular area and stores the result indestination.<ArgType> Tgeosearchstore(ArgType destination, ArgType source, @NonNull GeoSearchOrigin.SearchOrigin searchFrom, @NonNull GeoSearchShape searchBy, @NonNull GeoSearchResultOptions resultOptions)Searches for members in a sorted set stored atsourcerepresenting geospatial data within a circular or rectangular area and stores the result indestination.<ArgType> Tgeosearchstore(ArgType destination, ArgType source, @NonNull GeoSearchOrigin.SearchOrigin searchFrom, @NonNull GeoSearchShape searchBy, @NonNull GeoSearchStoreOptions options)Searches for members in a sorted set stored atsourcerepresenting geospatial data within a circular or rectangular area and stores the result indestination.<ArgType> Tgeosearchstore(ArgType destination, ArgType source, @NonNull GeoSearchOrigin.SearchOrigin searchFrom, @NonNull GeoSearchShape searchBy, @NonNull GeoSearchStoreOptions options, @NonNull GeoSearchResultOptions resultOptions)Searches for members in a sorted set stored atsourcerepresenting geospatial data within a circular or rectangular area and stores the result indestination.<ArgType> Tget(ArgType key)Gets the value associated with the givenkey, ornullif no suchkeyexists.<ArgType> Tgetbit(ArgType key, long offset)Returns the bit value atoffsetin the string value stored atkey.<ArgType> Tgetdel(ArgType key)Gets a string value associated with the givenkeyand deletes the key.<ArgType> Tgetex(ArgType key)Gets the value associated with the givenkey.<ArgType> Tgetex(ArgType key, @NonNull GetExOptions options)Gets the value associated with the givenkey.CommandRequestOuterClass.Batch.BuildergetProtobufBatch()Returns the protobuf batch builder.<ArgType> Tgetrange(ArgType key, int start, int end)Returns the substring of the string value stored atkey, determined by the offsetsstartandend(both are inclusive).protected abstract TgetThis()<ArgType> Thdel(ArgType key, @NonNull ArgType[] fields)Removes the specified fields from the hash stored atkey.<ArgType> Thexists(ArgType key, ArgType field)Returns iffieldis an existing field in the hash stored atkey.<ArgType> Thexpire(ArgType key, long seconds, @NonNull ArgType[] fields, @NonNull HashFieldExpirationConditionOptions options)Sets expiration time for hash fields.<ArgType> Thexpireat(ArgType key, long unixSeconds, @NonNull ArgType[] fields, @NonNull HashFieldExpirationConditionOptions options)Sets expiration time for hash fields, in seconds, using an absolute Unix timestamp.<ArgType> Thexpiretime(ArgType key, @NonNull ArgType[] fields)Returns the absolute Unix timestamp (in seconds) at which the given hash fields will expire.<ArgType> Thget(ArgType key, ArgType field)Retrieves the value associated withfieldin the hash stored atkey.<ArgType> Thgetall(ArgType key)Returns all fields and values of the hash stored atkey.<ArgType> Thgetex(ArgType key, @NonNull ArgType[] fields, @NonNull HGetExOptions options)Gets the values of the specified fields from the hash stored atkeyand optionally sets their expiration.
If a field does not exist in the hash, anullvalue is returned for that field.<ArgType> ThincrBy(ArgType key, ArgType field, long amount)Increments the number stored atfieldin the hash stored atkeyby increment.<ArgType> ThincrByFloat(ArgType key, ArgType field, double amount)Increments the string representing a floating point number stored atfieldin the hash stored atkeyby increment.<ArgType> Thkeys(ArgType key)Returns all field names in the hash stored atkey.<ArgType> Thlen(ArgType key)Returns the number of fields contained in the hash stored atkey.<ArgType> Thmget(ArgType key, @NonNull ArgType[] fields)Returns the values associated with the specified fields in the hash stored atkey.<ArgType> Thpersist(ArgType key, @NonNull ArgType[] fields)Removes the expiration time for each specified field, turning the field from volatile (a field with expiration time) to persistent (a field that will never expire as no expiration time is associated).<ArgType> Thpexpire(ArgType key, long milliseconds, @NonNull ArgType[] fields, @NonNull HashFieldExpirationConditionOptions options)Sets expiration time for hash fields, in milliseconds.<ArgType> Thpexpireat(ArgType key, long unixMilliseconds, @NonNull ArgType[] fields, @NonNull HashFieldExpirationConditionOptions options)Sets expiration time for hash fields, using an absolute Unix timestamp in milliseconds.<ArgType> Thpexpiretime(ArgType key, @NonNull ArgType[] fields)Returns the absolute Unix timestamp (in milliseconds) at which the given hash fields will expire.<ArgType> Thpttl(ArgType key, @NonNull ArgType[] fields)Returns the remaining time to live of hash fields that have a timeout, in milliseconds.<ArgType> Thrandfield(ArgType key)Returns a random field name from the hash value stored atkey.<ArgType> ThrandfieldWithCount(ArgType key, long count)Retrieves up tocountrandom field names from the hash value stored atkey.<ArgType> ThrandfieldWithCountWithValues(ArgType key, long count)Retrieves up tocountrandom field names along with their values from the hash value stored atkey.<ArgType> Thscan(ArgType key, ArgType cursor)Iterates fields of Hash types and their associated values.<ArgType> Thscan(ArgType key, ArgType cursor, @NonNull HScanOptions hScanOptions)Iterates fields of Hash types and their associated values.<ArgType> Thset(ArgType key, @NonNull java.util.Map<ArgType,ArgType> fieldValueMap)Sets the specified fields to their respective values in the hash stored atkey.<ArgType> Thsetex(ArgType key, @NonNull java.util.Map<ArgType,ArgType> fieldValueMap, @NonNull HSetExOptions options)Sets the specified fields to their respective values in the hash stored atkeywith optional expiration.<ArgType> Thsetnx(ArgType key, ArgType field, ArgType value)Setsfieldin the hash stored atkeytovalue, only iffielddoes not yet exist.
Ifkeydoes not exist, a new key holding a hash is created.
Iffieldalready exists, this operation has no effect.<ArgType> Thstrlen(ArgType key, ArgType field)Returns the string length of the value associated withfieldin the hash stored atkey.<ArgType> Thttl(ArgType key, @NonNull ArgType[] fields)Returns the remaining time to live of hash fields that have a timeout, in seconds.<ArgType> Thvals(ArgType key)Returns all values in the hash stored atkey.<ArgType> Tincr(ArgType key)Increments the number stored atkeyby one.<ArgType> TincrBy(ArgType key, long amount)Increments the number stored atkeybyamount.<ArgType> TincrByFloat(ArgType key, double amount)Increments the string representing a floating point number stored atkeybyamount.Tinfo()Gets information and statistics about the server using theInfoOptions.Section.DEFAULToption.Tinfo(@NonNull InfoOptions.Section[] sections)Gets information and statistics about the server.
Starting from server version 7, command supports multiple section arguments.booleanisBinaryOutput()Returns whether batch commands may return binary data.Tlastsave()ReturnsUNIX TIMEof the last DB save timestamp or startup timestamp if no save was made since then.<ArgType> Tlcs(ArgType key1, ArgType key2)Returns all the longest common subsequences combined between strings stored atkey1andkey2.<ArgType> TlcsIdx(ArgType key1, ArgType key2)Returns the indices and length of the longest common subsequence between strings stored atkey1andkey2.<ArgType> TlcsIdx(ArgType key1, ArgType key2, long minMatchLen)Returns the indices and the total length of all the longest common subsequences between strings stored atkey1andkey2.<ArgType> TlcsIdxWithMatchLen(ArgType key1, ArgType key2)Returns the indices and lengths of the longest common subsequences between strings stored atkey1andkey2.<ArgType> TlcsIdxWithMatchLen(ArgType key1, ArgType key2, long minMatchLen)Returns the indices and lengths of the longest common subsequences between strings stored atkey1andkey2.<ArgType> TlcsLen(ArgType key1, ArgType key2)Returns the total length of all the longest common subsequences between strings stored atkey1andkey2.<ArgType> Tlindex(ArgType key, long index)Returns the element atindexfrom the list stored atkey.
The index is zero-based, so0means the first element,1the second element and so on.<ArgType> Tlinsert(ArgType key, @NonNull LInsertOptions.InsertPosition position, ArgType pivot, ArgType element)Insertselementin the list atkeyeither before or after thepivot.<ArgType> Tllen(ArgType key)Returns the length of the list stored atkey.<ArgType> Tlmove(ArgType source, ArgType destination, @NonNull ListDirection whereFrom, @NonNull ListDirection whereTo)Atomically pops and removes the left/right-most element to the list stored atsourcedepending onwhereFrom, and pushes the element at the first/last element of the list stored atdestinationdepending onwhereFrom.<ArgType> Tlmpop(@NonNull ArgType[] keys, @NonNull ListDirection direction)Pops one element from the first non-empty list from the providedkeys.<ArgType> Tlmpop(@NonNull ArgType[] keys, @NonNull ListDirection direction, @NonNull java.lang.Long count)Pops one or more elements from the first non-empty list from the providedkeys.Tlolwut()Displays a piece of generative computer art and the server version.Tlolwut(int version)Displays a piece of generative computer art and the server version.Tlolwut(int @NonNull [] parameters)Displays a piece of generative computer art and the server version.Tlolwut(int version, int @NonNull [] parameters)Displays a piece of generative computer art and the server version.<ArgType> Tlpop(ArgType key)Removes and returns the first elements of the list stored atkey.<ArgType> TlpopCount(ArgType key, long count)Removes and returns up tocountelements of the list stored atkey, depending on the list's length.<ArgType> Tlpos(ArgType key, ArgType element)Returns the index of the first occurrence ofelementinside the list specified bykey.<ArgType> Tlpos(ArgType key, ArgType element, @NonNull LPosOptions options)Returns the index of an occurrence ofelementwithin a list based on the givenoptions.<ArgType> TlposCount(ArgType key, ArgType element, long count)Returns anarrayof indices of matching elements within a list.<ArgType> TlposCount(ArgType key, ArgType element, long count, @NonNull LPosOptions options)Returns anarrayof indices of matching elements within a list based on the givenoptions.<ArgType> Tlpush(ArgType key, @NonNull ArgType[] elements)Inserts all the specified values at the head of the list stored atkey.<ArgType> Tlpushx(ArgType key, @NonNull ArgType[] elements)Inserts all the specified values at the head of the list stored atkey, only ifkeyexists and holds a list.<ArgType> Tlrange(ArgType key, long start, long end)Returns the specified elements of the list stored atkey.
The offsetsstartandendare zero-based indexes, with0being the first element of the list,1being the next element and so on.<ArgType> Tlrem(ArgType key, long count, ArgType element)Removes the firstcountoccurrences of elements equal toelementfrom the list stored atkey.<ArgType> Tlset(ArgType key, long index, ArgType element)Sets the list element atindextoelement.
The index is zero-based, so0means the first element,1the second element and so on.<ArgType> Tltrim(ArgType key, long start, long end)Trims an existing list so that it will contain only the specified range of elements specified.<ArgType> Tmget(@NonNull ArgType[] keys)Retrieves the values of multiplekeys.<ArgType> Tmove(ArgType key, long dbIndex)Movekeyfrom the currently selected database to the database specified bydbIndex.Tmset(@NonNull java.util.Map<?,?> keyValueMap)Sets multiple keys to multiple values in a single operation.Tmsetnx(@NonNull java.util.Map<?,?> keyValueMap)Sets multiple keys to multiple values in a single operation.<ArgType> TobjectEncoding(ArgType key)Returns the internal encoding for the server object stored atkey.<ArgType> TobjectFreq(ArgType key)Returns the logarithmic access frequency counter of a server object stored atkey.<ArgType> TobjectIdletime(ArgType key)Returns the time in seconds since the last access to the value stored atkey.<ArgType> TobjectRefcount(ArgType key)Returns the reference count of the object stored atkey.<ArgType> Tpersist(ArgType key)Removes the existing timeout onkey, turning thekeyfrom volatile (akeywith an expire set) to persistent (akeythat will never expire as no timeout is associated).<ArgType> Tpexpire(ArgType key, long milliseconds)Sets a timeout onkeyin milliseconds.<ArgType> Tpexpire(ArgType key, long milliseconds, @NonNull ExpireOptions expireOptions)Sets a timeout onkeyin milliseconds.<ArgType> TpexpireAt(ArgType key, long unixMilliseconds)Sets a timeout onkey.<ArgType> TpexpireAt(ArgType key, long unixMilliseconds, @NonNull ExpireOptions expireOptions)Sets a timeout onkey.<ArgType> Tpexpiretime(ArgType key)Returns the absolute Unix timestamp (since January 1, 1970) at which the givenkeywill expire, in milliseconds.<ArgType> Tpfadd(ArgType key, @NonNull ArgType[] elements)Adds all elements to the HyperLogLog data structure stored at the specifiedkey.<ArgType> Tpfcount(@NonNull ArgType[] keys)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.<ArgType> Tpfmerge(ArgType destination, @NonNull ArgType[] sourceKeys)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.Tping()Pings the server.<ArgType> Tping(ArgType msg)Pings the server.<ArgType> Tpttl(ArgType key)Returns the remaining time to live ofkeythat has a timeout, in milliseconds.<ArgType> Tpublish(ArgType message, ArgType channel)Publishes message on pubsub channel.TpubsubChannels()Lists the currently active channels.<ArgType> TpubsubChannels(ArgType pattern)Lists the currently active channels.TpubsubNumPat()Returns the number of unique patterns that are subscribed to by clients.<ArgType> TpubsubNumSub(@NonNull ArgType[] channels)Returns the number of subscribers (exclusive of clients subscribed to patterns) for the specified channels.TrandomKey()Returns a random key from the currently selected database.<ArgType> Trename(ArgType key, ArgType newKey)RenameskeytonewKey.
IfnewKeyalready exists it is overwritten.<ArgType> Trenamenx(ArgType key, ArgType newKey)RenameskeytonewKeyifnewKeydoes not yet exist.Treset()Resets the connection state.<ArgType> Trestore(ArgType key, long ttl, @lombok.NonNull byte[] value)Create akeyassociated with avaluethat is obtained by deserializing the provided serializedvalue(obtained viadump(ArgType)).<ArgType> Trestore(ArgType key, long ttl, @lombok.NonNull byte[] value, @NonNull RestoreOptions restoreOptions)Create akeyassociated with avaluethat is obtained by deserializing the provided serializedvalue(obtained viadump(ArgType)).<ArgType> Trpop(ArgType key)Removes and returns the last elements of the list stored atkey.
The command pops a single element from the end of the list.<ArgType> TrpopCount(ArgType key, long count)Removes and returns up tocountelements from the list stored atkey, depending on the list's length.<ArgType> Trpush(ArgType key, @NonNull ArgType[] elements)Inserts all the specified values at the tail of the list stored atkey.
elementsare inserted one after the other to the tail of the list, from the leftmost element to the rightmost element.<ArgType> Trpushx(ArgType key, @NonNull ArgType[] elements)Inserts all the specified values at the tail of the list stored atkey, only ifkeyexists and holds a list.<ArgType> Tsadd(ArgType key, @NonNull ArgType[] members)Adds specified members to the set stored atkey.<ArgType> Tscard(ArgType key)Retrieves the set cardinality (number of elements) of the set stored atkey.<ArgType> Tsdiff(@NonNull ArgType[] keys)Computes the difference between the first set and all the successive sets inkeys.<ArgType> Tsdiffstore(ArgType destination, @NonNull ArgType[] keys)Stores the difference between the first set and all the successive sets inkeysinto a new set atdestination.<ArgType> Tset(ArgType key, ArgType value)Sets the given key with the given value.<ArgType> Tset(ArgType key, ArgType value, @NonNull SetOptions options)Sets the given key with the given value.<ArgType> Tsetbit(ArgType key, long offset, long value)Sets or clears the bit atoffsetin the string value stored atkey.<ArgType> Tsetrange(ArgType key, int offset, ArgType value)Overwrites part of the string stored atkey, starting at the specifiedoffset, for the entire length ofvalue.
If theoffsetis larger than the current length of the string atkey, the string is padded with zero bytes to makeoffsetfit.<ArgType> Tsinter(@NonNull ArgType[] keys)Gets the intersection of all the given sets.<ArgType> Tsintercard(@NonNull ArgType[] keys)Gets the cardinality of the intersection of all the given sets.<ArgType> Tsintercard(@NonNull ArgType[] keys, long limit)Gets the cardinality of the intersection of all the given sets.<ArgType> Tsinterstore(ArgType destination, @NonNull ArgType[] keys)Stores the members of the intersection of all given sets specified bykeysinto a new set atdestination.<ArgType> Tsismember(ArgType key, ArgType member)Returns ifmemberis a member of the set stored atkey.<ArgType> Tsmembers(ArgType key)Retrieves all the members of the set value stored atkey.<ArgType> Tsmismember(ArgType key, @NonNull ArgType[] members)Checks whether each member is contained in the members of the set stored atkey.<ArgType> Tsmove(ArgType source, ArgType destination, ArgType member)Movesmemberfrom the set atsourceto the set atdestination, removing it from the source set.<ArgType> Tsort(ArgType key)Sorts the elements in the list, set, or sorted set atkeyand returns the result.<ArgType> Tsort(ArgType key, @NonNull SortOptions sortOptions)Sorts the elements in the list, set, or sorted set atkeyand returns the result.<ArgType> TsortReadOnly(ArgType key)Sorts the elements in the list, set, or sorted set atkeyand returns the result.<ArgType> TsortReadOnly(ArgType key, @NonNull SortOptions sortOptions)Sorts the elements in the list, set, or sorted set atkeyand returns the result.<ArgType> TsortStore(ArgType key, ArgType destination)Sorts the elements in the list, set, or sorted set atkeyand stores the result indestination.<ArgType> TsortStore(ArgType key, ArgType destination, @NonNull SortOptions sortOptions)Sorts the elements in the list, set, or sorted set atkeyand stores the result indestination.<ArgType> Tspop(ArgType key)Removes and returns one random member from the set stored atkey.<ArgType> TspopCount(ArgType key, long count)Removes and returns up tocountrandom members from the set stored atkey, depending on the set's length.<ArgType> Tsrandmember(ArgType key)Returns a random element from the set value stored atkey.<ArgType> Tsrandmember(ArgType key, long count)Returns random elements from the set value stored atkey.<ArgType> Tsrem(ArgType key, @NonNull ArgType[] members)Removes specified members from the set stored atkey.<ArgType> Tsscan(ArgType key, ArgType cursor)Iterates incrementally over a set.<ArgType> Tsscan(ArgType key, ArgType cursor, @NonNull SScanOptions sScanOptions)Iterates incrementally over a set.<ArgType> Tstrlen(ArgType key)Returns the length of the string value stored atkey.<ArgType> Tsunion(@NonNull ArgType[] keys)Gets the union of all the given sets.<ArgType> Tsunionstore(ArgType destination, @NonNull ArgType[] keys)Stores the members of the union of all given sets specified bykeysinto a new set atdestination.Ttime()Returns the server time.<ArgType> Ttouch(@NonNull ArgType[] keys)Updates the last access time of specifiedkeys.<ArgType> Tttl(ArgType key)Returns the remaining time to live ofkeythat has a timeout.<ArgType> Ttype(ArgType key)Returns the string representation of the type of the value stored atkey.<ArgType> Tunlink(@NonNull ArgType[] keys)Unlinks (deletes) multiplekeysfrom the database.Twait(long numReplicas, long timeout)Returns the number of replicas that acknowledged the write commands sent by the current client before this command, both in the case where the specified number of replicas are reached, or when the timeout is reached.TwithBinaryOutput()SetsbinaryOutputtotrue.<ArgType> Txack(ArgType key, ArgType group, @NonNull ArgType[] ids)Returns the number of messages that were successfully acknowledged by the consumer group member of a stream.<ArgType> Txadd(ArgType key, @NonNull ArgType[][] values)Adds an entry to the specified stream stored atkey.
If thekeydoesn't exist, the stream is created.<ArgType> Txadd(ArgType key, @NonNull ArgType[][] values, @NonNull StreamAddOptions options)Adds an entry to the specified stream stored atkey.
If thekeydoesn't exist, the stream is created.<ArgType> Txadd(ArgType key, @NonNull java.util.Map<ArgType,ArgType> values)Adds an entry to the specified stream stored atkey.
If thekeydoesn't exist, the stream is created.<ArgType> Txadd(ArgType key, @NonNull java.util.Map<ArgType,ArgType> values, @NonNull StreamAddOptions options)Adds an entry to the specified stream stored atkey.
If thekeydoesn't exist, the stream is created.<ArgType> Txautoclaim(ArgType key, ArgType group, ArgType consumer, long minIdleTime, ArgType start)Transfers ownership of pending stream entries that match the specified criteria.<ArgType> Txautoclaim(ArgType key, ArgType group, ArgType consumer, long minIdleTime, ArgType start, long count)Transfers ownership of pending stream entries that match the specified criteria.<ArgType> TxautoclaimJustId(ArgType key, ArgType group, ArgType consumer, long minIdleTime, ArgType start)Transfers ownership of pending stream entries that match the specified criteria.<ArgType> TxautoclaimJustId(ArgType key, ArgType group, ArgType consumer, long minIdleTime, ArgType start, long count)Transfers ownership of pending stream entries that match the specified criteria.<ArgType> Txclaim(ArgType key, ArgType group, ArgType consumer, long minIdleTime, @NonNull ArgType[] ids)Changes the ownership of a pending message.<ArgType> Txclaim(ArgType key, ArgType group, ArgType consumer, long minIdleTime, @NonNull ArgType[] ids, @NonNull StreamClaimOptions options)Changes the ownership of a pending message.<ArgType> TxclaimJustId(ArgType key, ArgType group, ArgType consumer, long minIdleTime, @NonNull ArgType[] ids)Changes the ownership of a pending message.<ArgType> TxclaimJustId(ArgType key, ArgType group, ArgType consumer, long minIdleTime, @NonNull ArgType[] ids, @NonNull StreamClaimOptions options)Changes the ownership of a pending message.<ArgType> Txdel(ArgType key, @NonNull ArgType[] ids)Removes the specified entries by id from a stream, and returns the number of entries deleted.<ArgType> TxgroupCreate(ArgType key, ArgType groupName, ArgType id)Creates a new consumer group uniquely identified bygroupnamefor the stream stored atkey.<ArgType> TxgroupCreate(ArgType key, ArgType groupName, ArgType id, @NonNull StreamGroupOptions options)Creates a new consumer group uniquely identified bygroupnamefor the stream stored atkey.<ArgType> TxgroupCreateConsumer(ArgType key, ArgType group, ArgType consumer)Creates a consumer namedconsumerin the consumer groupgroupfor the stream stored atkey.<ArgType> TxgroupDelConsumer(ArgType key, ArgType group, ArgType consumer)Deletes a consumer namedconsumerin the consumer groupgroup.<ArgType> TxgroupDestroy(ArgType key, ArgType groupName)Destroys the consumer groupgroupNamefor the stream stored atkey.<ArgType> TxgroupSetId(ArgType key, ArgType groupName, ArgType id)Sets the last delivered ID for a consumer group.<ArgType> TxgroupSetId(ArgType key, ArgType groupName, ArgType id, long entriesRead)Sets the last delivered ID for a consumer group.<ArgType> TxinfoConsumers(ArgType key, ArgType groupName)Returns the list of all consumers and their attributes for the given consumer group of the stream stored atkey.<ArgType> TxinfoGroups(ArgType key)Returns the list of all consumer groups and their attributes for the stream stored atkey.<ArgType> TxinfoStream(ArgType key)Returns information about the stream stored at keykey.
To get more detailed information use#xinfoStreamFull(ArgType)or#xinfoStreamFull(ArgType, int).<ArgType> TxinfoStreamFull(ArgType key)Returns verbose information about the stream stored at keykey.
The output is limited by first10PEL entries.<ArgType> TxinfoStreamFull(ArgType key, int count)Returns verbose information about the stream stored at keykey.
The output is limited by first10PEL entries.<ArgType> Txlen(ArgType key)Returns the number of entries in the stream stored atkey.<ArgType> Txpending(ArgType key, ArgType group)Returns stream message summary information for pending messages matching a given range of IDs.<ArgType> Txpending(ArgType key, ArgType group, @NonNull StreamRange start, @NonNull StreamRange end, long count)Returns an extended form of stream message information for pending messages matching a given range of IDs.<ArgType> Txpending(ArgType key, ArgType group, @NonNull StreamRange start, @NonNull StreamRange end, long count, @NonNull StreamPendingOptions options)Returns an extended form of stream message information for pending messages matching a given range of IDs.<ArgType> Txrange(ArgType key, @NonNull StreamRange start, @NonNull StreamRange end)Returns stream entries matching a given range of IDs.<ArgType> Txrange(ArgType key, @NonNull StreamRange start, @NonNull StreamRange end, long count)Returns stream entries matching a given range of IDs.<ArgType> Txread(@NonNull java.util.Map<ArgType,ArgType> keysAndIds)Reads entries from the given streams.<ArgType> Txread(@NonNull java.util.Map<ArgType,ArgType> keysAndIds, @NonNull StreamReadOptions options)Reads entries from the given streams.<ArgType> Txreadgroup(@NonNull java.util.Map<ArgType,ArgType> keysAndIds, ArgType group, ArgType consumer)Reads entries from the given streams owned by a consumer group.<ArgType> Txreadgroup(@NonNull java.util.Map<ArgType,ArgType> keysAndIds, ArgType group, ArgType consumer, @NonNull StreamReadGroupOptions options)Reads entries from the given streams owned by a consumer group.<ArgType> Txrevrange(ArgType key, @NonNull StreamRange end, @NonNull StreamRange start)Returns stream entries matching a given range of IDs in reverse order.
Equivalent to#xrange(ArgType, StreamRange, StreamRange)but returns the entries in reverse order.<ArgType> Txrevrange(ArgType key, @NonNull StreamRange end, @NonNull StreamRange start, long count)Returns stream entries matching a given range of IDs in reverse order.
Equivalent to#xrange(ArgType, StreamRange, StreamRange, long)but returns the entries in reverse order.<ArgType> Txtrim(ArgType key, @NonNull StreamTrimOptions options)Trims the stream by evicting older entries.<ArgType> Tzadd(ArgType key, @NonNull java.util.Map<ArgType,java.lang.Double> membersScoresMap)Adds members with their scores to the sorted set stored atkey.
If a member is already a part of the sorted set, its score is updated.<ArgType> Tzadd(ArgType key, @NonNull java.util.Map<ArgType,java.lang.Double> membersScoresMap, boolean changed)Adds members with their scores to the sorted set stored atkey.
If a member is already a part of the sorted set, its score is updated.<ArgType> Tzadd(ArgType key, @NonNull java.util.Map<ArgType,java.lang.Double> membersScoresMap, @NonNull ZAddOptions options)Adds members with their scores to the sorted set stored atkey.
If a member is already a part of the sorted set, its score is updated.<ArgType> Tzadd(ArgType key, @NonNull java.util.Map<ArgType,java.lang.Double> membersScoresMap, @NonNull ZAddOptions options, boolean changed)Adds members with their scores to the sorted set stored atkey.
If a member is already a part of the sorted set, its score is updated.<ArgType> TzaddIncr(ArgType key, ArgType member, double increment)Increments the score of member in the sorted set stored atkeybyincrement.
Ifmemberdoes not exist in the sorted set, it is added withincrementas its score (as if its previous score was 0.0).
Ifkeydoes not exist, a new sorted set with the specified member as its sole member is created.<ArgType> TzaddIncr(ArgType key, ArgType member, double increment, @NonNull ZAddOptions options)Increments the score of member in the sorted set stored atkeybyincrement.
Ifmemberdoes not exist in the sorted set, it is added withincrementas its score (as if its previous score was 0.0).
Ifkeydoes not exist, a new sorted set with the specified member as its sole member is created.
zaddIncrwith empty option acts as#zincrby(ArgType, double, ArgType).<ArgType> Tzcard(ArgType key)Returns the cardinality (number of elements) of the sorted set stored atkey.<ArgType> Tzcount(ArgType key, @NonNull RangeOptions.ScoreRange minScore, @NonNull RangeOptions.ScoreRange maxScore)Returns the number of members in the sorted set stored atkeywith scores betweenminScoreandmaxScore.<ArgType> Tzdiff(@NonNull ArgType[] keys)Returns the difference between the first sorted set and all the successive sorted sets.
To get the elements with their scores, seezdiffWithScores(ArgType[]).<ArgType> Tzdiffstore(ArgType destination, @NonNull ArgType[] keys)Calculates the difference between the first sorted set and all the successive sorted sets atkeysand stores the difference as a sorted set todestination, overwriting it if it already exists.<ArgType> TzdiffWithScores(@NonNull ArgType[] keys)Returns the difference between the first sorted set and all the successive sorted sets.<ArgType> Tzincrby(ArgType key, double increment, ArgType member)Increments the score ofmemberin the sorted set stored atkeybyincrement.
Ifmemberdoes not exist in the sorted set, it is added withincrementas its score.Tzinter(@NonNull WeightAggregateOptions.KeyArray keys)Returns the intersection of members from sorted sets specified by the givenkeys.Tzinter(@NonNull WeightAggregateOptions.KeyArrayBinary keys)Returns the intersection of members from sorted sets specified by the givenkeys.<ArgType> Tzintercard(@NonNull ArgType[] keys)Returns the cardinality of the intersection of the sorted sets specified bykeys.<ArgType> Tzintercard(@NonNull ArgType[] keys, long limit)Returns the cardinality of the intersection of the sorted sets specified bykeys.Tzinterstore(@NonNull GlideString destination, @NonNull WeightAggregateOptions.KeysOrWeightedKeysBinary keysOrWeightedKeys)Computes the intersection of sorted sets given by the specifiedKeysOrWeightedKeys, and stores the result indestination.Tzinterstore(@NonNull GlideString destination, @NonNull WeightAggregateOptions.KeysOrWeightedKeysBinary keysOrWeightedKeys, @NonNull WeightAggregateOptions.Aggregate aggregate)Computes the intersection of sorted sets given by the specifiedkeysOrWeightedKeys, and stores the result indestination.Tzinterstore(@NonNull java.lang.String destination, @NonNull WeightAggregateOptions.KeysOrWeightedKeys keysOrWeightedKeys)Computes the intersection of sorted sets given by the specifiedKeysOrWeightedKeys, and stores the result indestination.Tzinterstore(@NonNull java.lang.String destination, @NonNull WeightAggregateOptions.KeysOrWeightedKeys keysOrWeightedKeys, @NonNull WeightAggregateOptions.Aggregate aggregate)Computes the intersection of sorted sets given by the specifiedkeysOrWeightedKeys, and stores the result indestination.TzinterWithScores(@NonNull WeightAggregateOptions.KeysOrWeightedKeys keysOrWeightedKeys)Returns the intersection of members and their scores from sorted sets specified by the givenkeysOrWeightedKeys.TzinterWithScores(@NonNull WeightAggregateOptions.KeysOrWeightedKeysBinary keysOrWeightedKeys)Returns the intersection of members and their scores from sorted sets specified by the givenkeysOrWeightedKeys.TzinterWithScores(@NonNull WeightAggregateOptions.KeysOrWeightedKeysBinary keysOrWeightedKeys, @NonNull WeightAggregateOptions.Aggregate aggregate)Returns the intersection of members and their scores from sorted sets specified by the givenkeysOrWeightedKeys.TzinterWithScores(@NonNull WeightAggregateOptions.KeysOrWeightedKeys keysOrWeightedKeys, @NonNull WeightAggregateOptions.Aggregate aggregate)Returns the intersection of members and their scores from sorted sets specified by the givenkeysOrWeightedKeys.<ArgType> Tzlexcount(ArgType key, @NonNull RangeOptions.LexRange minLex, @NonNull RangeOptions.LexRange maxLex)Returns the number of members in the sorted set stored atkeywith scores betweenminLexandmaxLex.<ArgType> Tzmpop(@NonNull ArgType[] keys, @NonNull ScoreFilter modifier)Pops a member-score pair from the first non-empty sorted set, with the givenkeysbeing checked in the order they are provided.<ArgType> Tzmpop(@NonNull ArgType[] keys, @NonNull ScoreFilter modifier, long count)Pops multiple member-score pairs from the first non-empty sorted set, with the givenkeysbeing checked in the order they are provided.<ArgType> Tzmscore(ArgType key, @NonNull ArgType[] members)Returns the scores associated with the specifiedmembersin the sorted set stored atkey.<ArgType> Tzpopmax(ArgType key)Removes and returns the member with the highest score from the sorted set stored at the specifiedkey.<ArgType> Tzpopmax(ArgType key, long count)Removes and returns up tocountmembers with the highest scores from the sorted set stored at the specifiedkey.<ArgType> Tzpopmin(ArgType key)Removes and returns the member with the lowest score from the sorted set stored at the specifiedkey.<ArgType> Tzpopmin(ArgType key, long count)Removes and returns up tocountmembers with the lowest scores from the sorted set stored at the specifiedkey.<ArgType> Tzrandmember(ArgType key)Returns a random element from the sorted set stored atkey.<ArgType> TzrandmemberWithCount(ArgType key, long count)Retrieves random elements from the sorted set stored atkey.<ArgType> TzrandmemberWithCountWithScores(ArgType key, long count)Retrieves random elements along with their scores from the sorted set stored atkey.<ArgType> Tzrange(ArgType key, @NonNull RangeOptions.RangeQuery rangeQuery)Returns the specified range of elements in the sorted set stored atkey.
ZRANGEcan perform different types of range queries: by index (rank), by the score, or by lexicographical order.
To get the elements with their scores, seezrangeWithScores(ArgType, glide.api.models.commands.RangeOptions.ScoredRangeQuery, boolean).<ArgType> Tzrange(ArgType key, @NonNull RangeOptions.RangeQuery rangeQuery, boolean reverse)Returns the specified range of elements in the sorted set stored atkey.
ZRANGEcan perform different types of range queries: by index (rank), by the score, or by lexicographical order.
To get the elements with their scores, seezrangeWithScores(ArgType, glide.api.models.commands.RangeOptions.ScoredRangeQuery, boolean).<ArgType> Tzrangestore(ArgType destination, ArgType source, @NonNull RangeOptions.RangeQuery rangeQuery)Stores a specified range of elements from the sorted set atsource, into a new sorted set atdestination.<ArgType> Tzrangestore(ArgType destination, ArgType source, @NonNull RangeOptions.RangeQuery rangeQuery, boolean reverse)Stores a specified range of elements from the sorted set atsource, into a new sorted set atdestination.<ArgType> TzrangeWithScores(ArgType key, @NonNull RangeOptions.ScoredRangeQuery rangeQuery)Returns the specified range of elements with their scores in the sorted set stored atkey.<ArgType> TzrangeWithScores(ArgType key, @NonNull RangeOptions.ScoredRangeQuery rangeQuery, boolean reverse)Returns the specified range of elements with their scores in the sorted set stored atkey.<ArgType> Tzrank(ArgType key, ArgType member)Returns the rank ofmemberin the sorted set stored atkey, with scores ordered from low to high, starting from0.
To get the rank ofmemberwith its score, seezrankWithScore(ArgType, ArgType).<ArgType> TzrankWithScore(ArgType key, ArgType member)Returns the rank ofmemberin the sorted set stored atkeywith its score, where scores are ordered from the lowest to highest, starting from0.<ArgType> Tzrem(ArgType key, @NonNull ArgType[] members)Removes the specified members from the sorted set stored atkey.
Specified members that are not a member of this set are ignored.<ArgType> Tzremrangebylex(ArgType key, @NonNull RangeOptions.LexRange minLex, @NonNull RangeOptions.LexRange maxLex)Removes all elements in the sorted set stored atkeywith a lexicographical order betweenminLexandmaxLex.<ArgType> Tzremrangebyrank(ArgType key, long start, long end)Removes all elements in the sorted set stored atkeywith rank betweenstartandend.<ArgType> Tzremrangebyscore(ArgType key, @NonNull RangeOptions.ScoreRange minScore, @NonNull RangeOptions.ScoreRange maxScore)Removes all elements in the sorted set stored atkeywith a score betweenminScoreandmaxScore.<ArgType> Tzrevrank(ArgType key, ArgType member)Returns the rank ofmemberin the sorted set stored atkey, where scores are ordered from the highest to lowest, starting from0.
To get the rank ofmemberwith its score, seezrevrankWithScore(ArgType, ArgType).<ArgType> TzrevrankWithScore(ArgType key, ArgType member)Returns the rank ofmemberin the sorted set stored atkeywith its score, where scores are ordered from the highest to lowest, starting from0.<ArgType> Tzscan(ArgType key, ArgType cursor)Iterates incrementally over a sorted set.<ArgType> Tzscan(ArgType key, ArgType cursor, @NonNull ZScanOptions zScanOptions)Iterates incrementally over a sorted set.<ArgType> Tzscore(ArgType key, ArgType member)Returns the score ofmemberin the sorted set stored atkey.Tzunion(@NonNull WeightAggregateOptions.KeyArray keys)Returns the union of members from sorted sets specified by the givenkeys.
To get the elements with their scores, seezunionWithScores(glide.api.models.commands.WeightAggregateOptions.KeysOrWeightedKeys, glide.api.models.commands.WeightAggregateOptions.Aggregate).Tzunion(@NonNull WeightAggregateOptions.KeyArrayBinary keys)Returns the union of members from sorted sets specified by the givenkeys.
To get the elements with their scores, seezunionWithScores(glide.api.models.commands.WeightAggregateOptions.KeysOrWeightedKeys, glide.api.models.commands.WeightAggregateOptions.Aggregate).Tzunionstore(@NonNull GlideString destination, @NonNull WeightAggregateOptions.KeysOrWeightedKeysBinary keysOrWeightedKeys)Computes the union of sorted sets given by the specifiedKeysOrWeightedKeys, and stores the result indestination.Tzunionstore(@NonNull GlideString destination, @NonNull WeightAggregateOptions.KeysOrWeightedKeysBinary keysOrWeightedKeys, @NonNull WeightAggregateOptions.Aggregate aggregate)Computes the union of sorted sets given by the specifiedKeysOrWeightedKeys, and stores the result indestination.Tzunionstore(@NonNull java.lang.String destination, @NonNull WeightAggregateOptions.KeysOrWeightedKeys keysOrWeightedKeys)Computes the union of sorted sets given by the specifiedKeysOrWeightedKeys, and stores the result indestination.Tzunionstore(@NonNull java.lang.String destination, @NonNull WeightAggregateOptions.KeysOrWeightedKeys keysOrWeightedKeys, @NonNull WeightAggregateOptions.Aggregate aggregate)Computes the union of sorted sets given by the specifiedKeysOrWeightedKeys, and stores the result indestination.TzunionWithScores(@NonNull WeightAggregateOptions.KeysOrWeightedKeys keysOrWeightedKeys)Returns the union of members and their scores from sorted sets specified by the givenkeysOrWeightedKeys.
To perform azunionoperation while specifying aggregation settings, usezunionWithScores(KeysOrWeightedKeys, Aggregate).TzunionWithScores(@NonNull WeightAggregateOptions.KeysOrWeightedKeysBinary keysOrWeightedKeys)Returns the union of members and their scores from sorted sets specified by the givenkeysOrWeightedKeys.
To perform azunionoperation while specifying aggregation settings, usezunionWithScores(KeysOrWeightedKeys, Aggregate).TzunionWithScores(@NonNull WeightAggregateOptions.KeysOrWeightedKeysBinary keysOrWeightedKeys, @NonNull WeightAggregateOptions.Aggregate aggregate)Returns the union of members and their scores from sorted sets specified by the givenkeysOrWeightedKeys.TzunionWithScores(@NonNull WeightAggregateOptions.KeysOrWeightedKeys keysOrWeightedKeys, @NonNull WeightAggregateOptions.Aggregate aggregate)Returns the union of members and their scores from sorted sets specified by the givenkeysOrWeightedKeys.
-
-
-
Field Detail
-
protobufBatch
protected final CommandRequestOuterClass.Batch.Builder protobufBatch
Command class to send a single request to Valkey.
-
binaryOutput
protected boolean binaryOutput
Flag whether batch commands may return binary data.
If set totrue, all commands in this batch returnGlideStringinstead ofString.
-
-
Method Detail
-
getProtobufBatch
public CommandRequestOuterClass.Batch.Builder getProtobufBatch()
Returns the protobuf batch builder. Batch builder is intentionally mutable for command assembly.
-
isBinaryOutput
public boolean isBinaryOutput()
Returns whether batch commands may return binary data.
-
withBinaryOutput
public T withBinaryOutput()
SetsbinaryOutputtotrue.
-
getThis
protected abstract T getThis()
-
customCommand
public <ArgType> T customCommand(ArgType[] args)
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- Arguments for the custom command.- Returns:
- Command Response - The returned value for the custom command.
-
echo
public <ArgType> T echo(@NonNull ArgType message)
Echoes the providedmessageback.- Parameters:
message- The message to be echoed back.- Returns:
- Command Response - The provided
message. - See Also:
- valkey.io for details.
-
ping
public T ping()
Pings the server.- Returns:
- Command Response - A response from the server with a
String. - See Also:
- valkey.io for details.
-
reset
public T reset()
Resets the connection state.- Returns:
- Command Response - A response from the server with a
String. - See Also:
- valkey.io for details.
-
ping
public <ArgType> T ping(@NonNull ArgType msg)
Pings the server.- Parameters:
msg- The ping argument that will be returned.- Returns:
- Command Response - A response from the server with a
String. - See Also:
- valkey.io for details.
-
info
public T info()
Gets information and statistics about the server using theInfoOptions.Section.DEFAULToption.- Returns:
- Command Response - A
Stringwith server info. - See Also:
- valkey.io for details.
-
info
public T info(@NonNull @NonNull InfoOptions.Section[] sections)
Gets information and statistics about the server.
Starting from server version 7, command supports multiple section arguments.- Parameters:
sections- A list ofInfoOptions.Sectionvalues specifying which sections of information to retrieve. When no parameter is provided, theInfoOptions.Section.DEFAULToption is assumed.- Returns:
- Command Response - A
Stringcontaining the requestedInfoOptions.Sections. - See Also:
- valkey.io for details.
-
del
public <ArgType> T del(@NonNull @NonNull ArgType[] keys)
Removes the specifiedkeysfrom the database. A key is ignored if it does not exist.- Parameters:
keys- The keys we wanted to remove.- Returns:
- Command Response - The number of keys that were removed.
- See Also:
- valkey.io for details.
-
get
public <ArgType> T get(@NonNull ArgType key)
Gets the value associated with the givenkey, ornullif no suchkeyexists.- Parameters:
key- The key to retrieve from the database.- Returns:
- Command Response - If
keyexists, returns thevalueofkeyas a String. Otherwise, returnnull. - See Also:
- valkey.io for details.
-
getdel
public <ArgType> T getdel(@NonNull ArgType key)
Gets a string value associated with the givenkeyand deletes the key.- Parameters:
key- Thekeyto retrieve from the database.- Returns:
- Command Response - If
keyexists, returns thevalueofkey. Otherwise, returnnull. - See Also:
- valkey.io for details.
-
getex
public <ArgType> T getex(@NonNull ArgType key)
Gets the value associated with the givenkey.- Parameters:
key- Thekeyto retrieve from the database.- Returns:
- Command Response - If
keyexists, return thevalueof thekey. Otherwise, returnnull. - Since:
- Valkey 6.2.0.
- See Also:
- valkey.io for details.
-
getex
public <ArgType> T getex(@NonNull ArgType key, @NonNull @NonNull GetExOptions options)
Gets the value associated with the givenkey.- Parameters:
key- Thekeyto retrieve from the database.options- TheGetExOptionsoptions.- Returns:
- Command Response - If
keyexists, return thevalueof thekey. Otherwise, returnnull. - Since:
- Valkey 6.2.0.
- See Also:
- valkey.io for details.
-
set
public <ArgType> T set(@NonNull ArgType key, @NonNull ArgType value)
Sets the given key with the given value.- Parameters:
key- The key to store.value- The value to store with the givenkey.- Returns:
- Command Response -
"OK"response on success. - See Also:
- valkey.io for details.
-
set
public <ArgType> T set(@NonNull ArgType key, @NonNull ArgType value, @NonNull @NonNull SetOptions options)
Sets 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.- Returns:
- Command Response - A
Stringornullresponse. The old value as aStringifSetOptions.SetOptionsBuilder.returnOldValue(boolean)is set. Otherwise, if the value isn't set because ofSetOptions.ConditionalSet.ONLY_IF_EXISTSorSetOptions.ConditionalSet.ONLY_IF_DOES_NOT_EXISTconditions, returnnull. Otherwise, returnOK. - See Also:
- valkey.io for details.
-
append
public <ArgType> T append(@NonNull ArgType key, @NonNull ArgType value)
Appends avalueto akey. Ifkeydoes not exist it is created and set as an empty string, soAPPENDwill be similar toset(ArgType, ArgType)in this special case.- Parameters:
key- The key of the string.value- The value to append.- Returns:
- Command Response - The length of the string after appending the value.
- See Also:
- valkey.io for details.
-
mget
public <ArgType> T mget(@NonNull @NonNull ArgType[] keys)
Retrieves the values of multiplekeys.- Parameters:
keys- A list of keys to retrieve values for.- Returns:
- Command Response - An
arrayof values corresponding to the providedkeys.
If akeyis not found, its corresponding value in the list will benull. - See Also:
- valkey.io for details.
-
mset
public T mset(@NonNull @NonNull java.util.Map<?,?> keyValueMap)
Sets multiple keys to multiple values in a single operation.- Parameters:
keyValueMap- A key-value map consisting of keys and their respective values to set.- Returns:
- Command Response -
"OK"response on success. - See Also:
- valkey.io for details.
-
msetnx
public T msetnx(@NonNull @NonNull java.util.Map<?,?> keyValueMap)
Sets multiple keys to multiple values in a single operation. Performs no operation at all even if just a single key already exists.- Parameters:
keyValueMap- A key-value map consisting of keys and their respective values to set.- Returns:
- Command Response -
trueif all keys were set,falseif no key was set. - See Also:
- valkey.io for details.
-
move
public <ArgType> T move(ArgType key, long dbIndex)
Movekeyfrom the currently selected database to the database specified bydbIndex.- Parameters:
key- The key to move.dbIndex- The index of the database to movekeyto.- Returns:
- Command Response -
trueifkeywas moved, orfalseif thekeyalready exists in the destination database or does not exist in the source database. - See Also:
- valkey.io for more details.
-
incr
public <ArgType> T incr(@NonNull ArgType key)
Increments the number stored atkeyby one. Ifkeydoes not exist, it is set to 0 before performing the operation.- Parameters:
key- The key to increment its value.- Returns:
- Command Response - The value of
keyafter the increment. - See Also:
- valkey.io for details.
-
incrBy
public <ArgType> T incrBy(@NonNull ArgType key, long amount)
Increments the number stored atkeybyamount. Ifkeydoes not exist, it is set to 0 before performing the operation.- Parameters:
key- The key to increment its value.amount- The amount to increment.- Returns:
- Command Response - The value of
keyafter the increment. - See Also:
- valkey.io for details.
-
incrByFloat
public <ArgType> T incrByFloat(@NonNull ArgType key, double amount)
Increments the string representing a floating point number stored atkeybyamount. By using a negative increment value, the result is that the value stored atkeyis decremented. Ifkeydoes not exist, it is set to 0 before performing the operation.- Parameters:
key- The key to increment its value.amount- The amount to increment.- Returns:
- Command Response - The value of
keyafter the increment. - See Also:
- valkey.io for details.
-
decr
public <ArgType> T decr(@NonNull ArgType key)
Decrements the number stored atkeyby one. Ifkeydoes not exist, it is set to 0 before performing the operation.- Parameters:
key- The key to decrement its value.- Returns:
- Command Response - The value of
keyafter the decrement. - See Also:
- valkey.io for details.
-
decrBy
public <ArgType> T decrBy(@NonNull ArgType key, long amount)
Decrements the number stored atkeybyamount. Ifkeydoes not exist, it is set to 0 before performing the operation.- Parameters:
key- The key to decrement its value.amount- The amount to decrement.- Returns:
- Command Response - The value of
keyafter the decrement. - See Also:
- valkey.io for details.
-
strlen
public <ArgType> T strlen(@NonNull ArgType key)
Returns the length of the string value stored atkey.- Parameters:
key- The key to check its length.- Returns:
- Command Response - The length of the string value stored at key.
Ifkeydoes not exist, it is treated as an empty string, and the command returns0. - See Also:
- valkey.io for details.
-
setrange
public <ArgType> T setrange(@NonNull ArgType key, int offset, @NonNull ArgType value)
Overwrites part of the string stored atkey, starting at the specifiedoffset, for the entire length ofvalue.
If theoffsetis larger than the current length of the string atkey, the string is padded with zero bytes to makeoffsetfit. Creates thekeyif it doesn't exist.- Parameters:
key- The key of the string to update.offset- The position in the string wherevalueshould be written.value- The string written withoffset.- Returns:
- Command Response - The length of the string stored at
keyafter it was modified. - See Also:
- valkey.io for details.
-
getrange
public <ArgType> T getrange(@NonNull ArgType key, int start, int end)
Returns the substring of the string value stored atkey, determined by the offsetsstartandend(both are inclusive). Negative offsets can be used in order to provide an offset starting from the end of the string. So-1means the last character,-2the penultimate and so forth. Ifkeydoes not exist, an empty string is returned. Ifstartorendare out of range, returns the substring within the valid range of the string.- Parameters:
key- The key of the string.start- The starting offset.end- The ending offset.- Returns:
- Command Response - A substring extracted from the value stored at
key. - See Also:
- valkey.io for details.
-
hget
public <ArgType> T hget(@NonNull ArgType key, @NonNull ArgType field)
Retrieves the value associated withfieldin the hash stored atkey.- Parameters:
key- The key of the hash.field- The field in the hash stored atkeyto retrieve from the database.- Returns:
- Command Response - The value associated with
field, ornullwhenfieldis not present in the hash orkeydoes not exist. - See Also:
- valkey.io for details.
-
hset
public <ArgType> T hset(@NonNull ArgType key, @NonNull @NonNull java.util.Map<ArgType,ArgType> fieldValueMap)
Sets the specified fields to their respective values in the hash stored atkey.- Parameters:
key- The key of the hash.fieldValueMap- A field-value map consisting of fields and their corresponding values to be set in the hash stored at the specified key.- Returns:
- Command Response - The number of fields that were added.
- See Also:
- valkey.io for details.
-
hsetex
public <ArgType> T hsetex(@NonNull ArgType key, @NonNull @NonNull java.util.Map<ArgType,ArgType> fieldValueMap, @NonNull @NonNull HSetExOptions options)
Sets the specified fields to their respective values in the hash stored atkeywith optional expiration. Ifkeydoes not exist, a new key holding a hash is created.- Parameters:
key- The key of the hash.fieldValueMap- A field-value map consisting of fields and their corresponding values to be set in the hash stored at the specified key.options- TheHSetExOptionsfor the command, including field conditional changes and expiry settings.- Returns:
- Command Response - The number of fields that were added to the hash.
- Since:
- Valkey 9.0.0.
- See Also:
- valkey.io for details.
- Example:
// Set fields with 60 second expiration, only if none exist HSetExOptions options = HSetExOptions.builder() .onlyIfNoneExist() .expiry(ExpirySet.Seconds(60L)) .build(); Map<String, String> fieldValueMap = Map.of("field1", "value1", "field2", "value2"); batch.hsetex("myHash", fieldValueMap, options);
-
hgetex
public <ArgType> T hgetex(@NonNull ArgType key, @NonNull @NonNull ArgType[] fields, @NonNull @NonNull HGetExOptions options)
Gets the values of the specified fields from the hash stored atkeyand optionally sets their expiration.
If a field does not exist in the hash, anullvalue is returned for that field.- Parameters:
key- The key of the hash.fields- The fields to retrieve from the hash.options- TheHGetExOptionsfor the command, including expiry settings that support PERSIST but exclude KEEPTTL.- Returns:
- Command Response - An array of values associated with the given fields, in the same
order as they are requested. For every field that does not exist in the hash, a
nullvalue is returned. - Since:
- Valkey 9.0.0.
- See Also:
- valkey.io for details.
- Example:
// Get fields and set them to persist (no expiration) HGetExOptions options = HGetExOptions.builder() .expiry(HGetExExpiry.Persist()) .build(); String[] fields = {"field1", "field2"}; batch.hgetex("myHash", fields, options);
-
hexpire
public <ArgType> T hexpire(@NonNull ArgType key, long seconds, @NonNull @NonNull ArgType[] fields, @NonNull @NonNull HashFieldExpirationConditionOptions options)
Sets expiration time for hash fields. HEXPIRE sets the expiration time in seconds for the specified fields of the hash stored atkey. You can specify whether to set the expiration only if the field has no expiration, only if the field has an existing expiration, only if the new expiration is greater than the current one, or only if the new expiration is less than the current one.- Parameters:
key- The key of the hash.seconds- The expiration time in seconds.fields- The fields in the hash stored atkeyto set expiration for.options- TheHashFieldExpirationConditionOptionsfor the command, supporting only expiration conditions (NX/XX/GT/LT).- Returns:
- Command Response - An array of
Booleanvalues indicating the success of setting expiration for each field.trueindicates that the expiration was successfully set, andfalseindicates that the condition was not met or the field does not exist. - Since:
- Valkey 9.0 and above.
- See Also:
- valkey.io for details.
- Example:
// Set expiration only if fields have no existing expiration HashFieldExpirationConditionOptions options = HashFieldExpirationConditionOptions.builder() .onlyIfNoExpiry() .build(); String[] fields = {"field1", "field2"}; batch.hexpire("myHash", 300L, fields, options);
-
hpersist
public <ArgType> T hpersist(@NonNull ArgType key, @NonNull @NonNull ArgType[] fields)
Removes the expiration time for each specified field, turning the field from volatile (a field with expiration time) to persistent (a field that will never expire as no expiration time is associated).- Parameters:
key- The key of the hash.fields- The fields to remove expiration from.- Returns:
- Command Response - An array of
Booleanvalues, each corresponding to a field:trueif the expiration time was successfully removed from the field.falseif the field does not exist or does not have an expiration time.
- Since:
- Valkey 9.0 and above.
- See Also:
- valkey.io for details.
-
hpexpire
public <ArgType> T hpexpire(@NonNull ArgType key, long milliseconds, @NonNull @NonNull ArgType[] fields, @NonNull @NonNull HashFieldExpirationConditionOptions options)
Sets expiration time for hash fields, in milliseconds. Creates the hash if it doesn't exist. If a field is already expired, it will be deleted rather than expired.- Parameters:
key- The key of the hash.milliseconds- The expiration time to set for the fields, in milliseconds.fields- The fields to set expiration for.options- TheHashFieldExpirationConditionOptionsfor the command, supporting only expiration conditions (NX/XX/GT/LT).- Returns:
- Command response - An array of
Booleanvalues, each corresponding to a field:trueif the expiration time was successfully set for the field.falseif the field does not exist or the expiration time was not set due to the condition not being met.
- Since:
- Valkey 9.0 and above.
- See Also:
- valkey.io for details.
- Example:
// Set expiration only if new expiration is greater than current HashFieldExpirationConditionOptions options = HashFieldExpirationConditionOptions.builder() .onlyIfGreaterThanCurrent() .build(); String[] fields = {"field1", "field2"}; batch.hpexpire("myHash", 30000L, fields, options);
-
hexpireat
public <ArgType> T hexpireat(@NonNull ArgType key, long unixSeconds, @NonNull @NonNull ArgType[] fields, @NonNull @NonNull HashFieldExpirationConditionOptions options)
Sets expiration time for hash fields, in seconds, using an absolute Unix timestamp. Creates the hash if it doesn't exist. If a field is already expired, it will be deleted rather than expired.- Parameters:
key- The key of the hash.unixSeconds- The expiration time to set for the fields, as a Unix timestamp in seconds.fields- The fields to set expiration for.options- TheHashFieldExpirationConditionOptionsfor the command, supporting only expiration conditions (NX/XX/GT/LT).- Returns:
- Command response - An array of
Booleanvalues, each corresponding to a field:trueif the expiration time was successfully set for the field.falseif the field does not exist or the expiration time was not set due to the condition not being met.
- Since:
- Valkey 9.0 and above.
- See Also:
- valkey.io for details.
- Example:
// Set expiration only if fields have existing expiration HashFieldExpirationConditionOptions options = HashFieldExpirationConditionOptions.builder() .onlyIfHasExpiry() .build(); String[] fields = {"field1", "field2"}; long unixTimestamp = System.currentTimeMillis() / 1000 + 3600; // 1 hour from now batch.hexpireat("myHash", unixTimestamp, fields, options);
-
hpexpireat
public <ArgType> T hpexpireat(@NonNull ArgType key, long unixMilliseconds, @NonNull @NonNull ArgType[] fields, @NonNull @NonNull HashFieldExpirationConditionOptions options)
Sets expiration time for hash fields, using an absolute Unix timestamp in milliseconds.HPEXPIREAThas the same effect and semantic asHEXPIREAT, but the Unix time at which the field will expire is specified in milliseconds instead of seconds. Seehexpireat(Object, long, Object[], HashFieldExpirationConditionOptions)for more details.- Parameters:
key- The key of the hash.unixMilliseconds- The expiration time to set for the fields, as a Unix timestamp in milliseconds.fields- The fields to set expiration for.options- TheHashFieldExpirationConditionOptionsfor the command, supporting only expiration conditions (NX/XX/GT/LT).- Returns:
- Command response - An array of
Booleanvalues, each corresponding to a field:trueif the expiration time was successfully set for the field.falseif the field does not exist or the expiration time was not set due to the condition not being met.
- Since:
- Valkey 9.0 and above.
- See Also:
- valkey.io for details.
- Example:
// Set expiration only if new expiration is less than current HashFieldExpirationConditionOptions options = HashFieldExpirationConditionOptions.builder() .onlyIfLessThanCurrent() .build(); String[] fields = {"field1", "field2"}; long unixTimestamp = System.currentTimeMillis() + 1800000; // 30 minutes from now batch.hpexpireat("myHash", unixTimestamp, fields, options);
-
httl
public <ArgType> T httl(@NonNull ArgType key, @NonNull @NonNull ArgType[] fields)
Returns the remaining time to live of hash fields that have a timeout, in seconds.- Parameters:
key- The key of the hash.fields- The fields to get the TTL for.- Returns:
- Command Response - An array of
Longvalues, each corresponding to a field:- TTL in seconds if the field exists and has a timeout.
-1if the field exists but has no associated expire.-2if the field does not exist.
- Since:
- Valkey 9.0 and above.
- See Also:
- valkey.io for details.
-
hpttl
public <ArgType> T hpttl(@NonNull ArgType key, @NonNull @NonNull ArgType[] fields)
Returns the remaining time to live of hash fields that have a timeout, in milliseconds.- Parameters:
key- The key of the hash.fields- The fields to get the TTL for.- Returns:
- Command Response - An array of TTL values in milliseconds for the specified fields:
- For fields with a timeout, returns the remaining TTL in milliseconds.
- For fields that exist but have no associated expire, returns
-1. - For fields that do not exist, returns
-2.
- Since:
- Valkey 9.0 and above.
- See Also:
- valkey.io for details.
-
hexpiretime
public <ArgType> T hexpiretime(@NonNull ArgType key, @NonNull @NonNull ArgType[] fields)
Returns the absolute Unix timestamp (in seconds) at which the given hash fields will expire.- Parameters:
key- The key of the hash.fields- The fields to get the expiration timestamp for.- Returns:
- Command Response - An array of expiration timestamps in seconds for the specified
fields:
- For fields with a timeout, returns the absolute Unix timestamp in seconds.
- For fields that exist but have no associated expire, returns
-1. - For fields that do not exist, returns
-2.
- Since:
- Valkey 9.0 and above.
- See Also:
- valkey.io for details.
-
hpexpiretime
public <ArgType> T hpexpiretime(@NonNull ArgType key, @NonNull @NonNull ArgType[] fields)
Returns the absolute Unix timestamp (in milliseconds) at which the given hash fields will expire.- Parameters:
key- The key of the hash.fields- The fields to get the expiration timestamp for.- Returns:
- Command Response - An array of expiration timestamps in milliseconds for the specified
fields:
- For fields with a timeout, returns the absolute Unix timestamp in milliseconds.
- For fields that exist but have no associated expire, returns
-1. - For fields that do not exist, returns
-2.
- Since:
- Valkey 9.0 and above.
- See Also:
- valkey.io for details.
-
hsetnx
public <ArgType> T hsetnx(@NonNull ArgType key, @NonNull ArgType field, @NonNull ArgType value)
Setsfieldin the hash stored atkeytovalue, only iffielddoes not yet exist.
Ifkeydoes not exist, a new key holding a hash is created.
Iffieldalready 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.- Returns:
- Command Response -
trueif the field was set,falseif the field already existed and was not set. - See Also:
- valkey.io for details.
-
hdel
public <ArgType> T hdel(@NonNull ArgType key, @NonNull @NonNull ArgType[] fields)
Removes the specified fields from the hash stored atkey. 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 atkey.- Returns:
- Command Response - The number of fields that were removed from the hash, not including
specified but non-existing fields.
Ifkeydoes not exist, it is treated as an empty hash and it returns 0. - See Also:
- valkey.io for details.
-
hlen
public <ArgType> T hlen(@NonNull ArgType key)
Returns the number of fields contained in the hash stored atkey.- Parameters:
key- The key of the hash.- Returns:
- Command Response - The number of fields in the hash, or
0when the key does not exist.
Ifkeyholds a value that is not a hash, an error is returned. - See Also:
- valkey.io for details.
-
hvals
public <ArgType> T hvals(@NonNull ArgType key)
Returns all values in the hash stored atkey.- Parameters:
key- The key of the hash.- Returns:
- Command Response - An
arrayof values in the hash, or anempty arraywhen the key does not exist. - See Also:
- valkey.io for details.
-
hmget
public <ArgType> T hmget(@NonNull ArgType key, @NonNull @NonNull ArgType[] fields)
Returns the values associated with the specified fields in the hash stored atkey.- Parameters:
key- The key of the hash.fields- The fields in the hash stored atkeyto retrieve from the database.- Returns:
- Command Response - An array of values associated with the given fields, in the same
order as they are requested.
For every field that does not exist in the hash, anullvalue is returned.
Ifkeydoes not exist, it is treated as an empty hash, and it returns an array ofnullvalues. - See Also:
- valkey.io for details.
-
hexists
public <ArgType> T hexists(@NonNull ArgType key, @NonNull ArgType field)
Returns iffieldis an existing field in the hash stored atkey.- Parameters:
key- The key of the hash.field- The field to check in the hash stored atkey.- Returns:
- Command Response -
trueif the hash contains the specified field. If the hash does not contain the field, or if the key does not exist, it returnsfalse. - See Also:
- valkey.io for details.
-
hgetall
public <ArgType> T hgetall(@NonNull ArgType key)
Returns all fields and values of the hash stored atkey.- Parameters:
key- The key of the hash.- Returns:
- Command Response - A
Mapof fields and their values stored in the hash. Every field name in the map is associated with its corresponding value.
Ifkeydoes not exist, it returns an empty map. - See Also:
- valkey.io for details.
-
hincrBy
public <ArgType> T hincrBy(@NonNull ArgType key, @NonNull ArgType field, long amount)
Increments the number stored atfieldin the hash stored atkeyby increment. By using a negative increment value, the value stored atfieldin the hash stored atkeyis decremented. Iffieldorkeydoes 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 atkeyto increment or decrement its value.amount- The amount by which to increment or decrement the field's value. Use a negative value to decrement.- Returns:
- Command Response - The value of
fieldin the hash stored atkeyafter the increment or decrement. - See Also:
- valkey.io for details.
-
hincrByFloat
public <ArgType> T hincrByFloat(@NonNull ArgType key, @NonNull ArgType field, double amount)
Increments the string representing a floating point number stored atfieldin the hash stored atkeyby increment. By using a negative increment value, the value stored atfieldin the hash stored atkeyis decremented. Iffieldorkeydoes 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 atkeyto increment or decrement its value.amount- The amount by which to increment or decrement the field's value. Use a negative value to decrement.- Returns:
- Command Response - The value of
fieldin the hash stored atkeyafter the increment or decrement. - See Also:
- valkey.io for details.
-
hkeys
public <ArgType> T hkeys(@NonNull ArgType key)
Returns all field names in the hash stored atkey.- Parameters:
key- The key of the hash.- Returns:
- Command Response - An
arrayof field names in the hash, or anempty arraywhen the key does not exist. - See Also:
- valkey.io for details
-
hstrlen
public <ArgType> T hstrlen(@NonNull ArgType key, @NonNull ArgType field)
Returns the string length of the value associated withfieldin the hash stored atkey.- Parameters:
key- The key of the hash.field- The field in the hash.- Returns:
- Command Response - The string length or
0iffieldorkeydoes not exist. - See Also:
- valkey.io for details.
-
hrandfield
public <ArgType> T hrandfield(@NonNull ArgType key)
Returns a random field name from the hash value stored atkey.- Parameters:
key- The key of the hash.- Returns:
- Command Response - A random field name from the hash stored at
key, ornullwhen the key does not exist. - Since:
- Valkey 6.2 and above.
- See Also:
- valkey.io for details.
-
hrandfieldWithCount
public <ArgType> T hrandfieldWithCount(@NonNull ArgType key, long count)
Retrieves up tocountrandom field names from the hash value stored atkey.- Parameters:
key- The key of the hash.count- The number of field names to return.
Ifcountis positive, returns unique elements.
If negative, allows for duplicates.- Returns:
- Command Response - An
arrayof random field names from the hash stored atkey, or anempty arraywhen the key does not exist. - Since:
- Valkey 6.2 and above.
- See Also:
- valkey.io for details.
-
hrandfieldWithCountWithValues
public <ArgType> T hrandfieldWithCountWithValues(@NonNull ArgType key, long count)
Retrieves up tocountrandom field names along with their values from the hash value stored atkey.- Parameters:
key- The key of the hash.count- The number of field names to return.
Ifcountis positive, returns unique elements.
If negative, allows for duplicates.- Returns:
- Command Response - A 2D
arrayof[fieldName, value]arrays, wherefieldNameis a random field name from the hash andvalueis the associated value of the field name.
If the hash does not exist or is empty, the response will be an emptyarray. - Since:
- Valkey 6.2 and above.
- See Also:
- valkey.io for details.
-
lpush
public <ArgType> T lpush(@NonNull ArgType key, @NonNull @NonNull ArgType[] elements)
Inserts all the specified values at the head of the list stored atkey.elementsare inserted one after the other to the head of the list, from the leftmost element to the rightmost element. Ifkeydoes not exist, it is created as an 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 atkey.- Returns:
- Command Response - The length of the list after the push operations.
- See Also:
- valkey.io for details.
-
lpop
public <ArgType> T lpop(@NonNull ArgType key)
Removes and returns the first elements of the list stored atkey. The command pops a single element from the beginning of the list.- Parameters:
key- The key of the list.- Returns:
- Command Response - The value of the first element.
Ifkeydoes not exist,nullwill be returned. - See Also:
- valkey.io for details.
-
lpos
public <ArgType> T lpos(@NonNull ArgType key, @NonNull ArgType element)
Returns the index of the first occurrence ofelementinside the list specified bykey. If no match is found,nullis returned.- Parameters:
key- The name of the list.element- The value to search for within the list.- Returns:
- Command Response - The index of the first occurrence of
element, ornullifelementis not in the list. - Since:
- Valkey 6.0.6.
- See Also:
- valkey.io for details.
-
lpos
public <ArgType> T lpos(@NonNull ArgType key, @NonNull ArgType element, @NonNull @NonNull LPosOptions options)
Returns the index of an occurrence ofelementwithin a list based on the givenoptions. If no match is found,nullis returned.- Parameters:
key- The name of the list.element- The value to search for within the list.options- The LPos options.- Returns:
- Command Response - The index of
element, ornullifelementis not in the list. - Since:
- Valkey 6.0.6.
- See Also:
- valkey.io for details.
-
lposCount
public <ArgType> T lposCount(@NonNull ArgType key, @NonNull ArgType element, long count)
Returns anarrayof indices of matching elements within a list.- Parameters:
key- The name of the list.element- The value to search for within the list.count- The number of matches wanted.- Returns:
- Command Response - An
arraythat holds the indices of the matching elements within the list. - Since:
- Valkey 6.0.6.
- See Also:
- valkey.io for details.
-
lposCount
public <ArgType> T lposCount(@NonNull ArgType key, @NonNull ArgType element, long count, @NonNull @NonNull LPosOptions options)
Returns anarrayof indices of matching elements within a list based on the givenoptions. If no match is found, an emptyarrayis returned.- Parameters:
key- The name of the list.element- The value to search for within the list.count- The number of matches wanted.options- The LPos options.- Returns:
- Command Response - An
arraythat holds the indices of the matching elements within the list. - Since:
- Valkey 6.0.6.
- See Also:
- valkey.io for details.
-
lpopCount
public <ArgType> T lpopCount(@NonNull ArgType key, long count)
Removes and returns up tocountelements of the list stored atkey, depending on the list's length.- Parameters:
key- The key of the list.count- The count of the elements to pop from the list.- Returns:
- Command Response - An array of the popped elements will be returned depending on the
list's length.
Ifkeydoes not exist,nullwill be returned. - See Also:
- valkey.io for details.
-
lrange
public <ArgType> T lrange(@NonNull ArgType key, long start, long end)
Returns the specified elements of the list stored atkey.
The offsetsstartandendare zero-based indexes, with0being the first element of the list,1being the next element and so on. These offsets can also be negative numbers indicating offsets starting at the end of the list, with-1being the last element of the list,-2being the penultimate, and so on.- Parameters:
key- The key of the list.start- The starting point of the range.end- The end of the range.- Returns:
- Command Response - Array of elements in the specified range.
Ifstartexceeds the end of the list, or ifstartis greater thanend, an empty array will be returned.
Ifendexceeds the actual end of the list, the range will stop at the actual end of the list.
Ifkeydoes not exist an empty array will be returned. - See Also:
- valkey.io for details.
-
lindex
public <ArgType> T lindex(@NonNull ArgType key, long index)
Returns the element atindexfrom the list stored atkey.
The index is zero-based, so0means the first element,1the second element and so on. Negative indices can be used to designate elements starting at the tail of the list. Here,-1means the last element,-2means the penultimate and so forth.- Parameters:
key- The key of the list.index- The index of the element in the list to retrieve.- Returns:
- Command Response - The element at
indexin the list stored atkey.
Ifindexis out of range or ifkeydoes not exist,nullis returned. - See Also:
- valkey.io for details.
-
ltrim
public <ArgType> T ltrim(@NonNull ArgType key, long start, long end)
Trims an existing list so that it will contain only the specified range of elements specified.
The offsetsstartandendare zero-based indexes, with0being the first element of the list,1being the next element and so on.
These offsets can also be negative numbers indicating offsets starting at the end of the list, with-1being the last element of the list,-2being the penultimate, and so on.- Parameters:
key- The key of the list.start- The starting point of the range.end- The end of the range.- Returns:
- Command Response -
"OK"response on success.
Ifstartexceeds the end of the list, or ifstartis greater thanend, the list is emptied and the key is removed.
Ifendexceeds the actual end of the list, it will be treated like the last element of the list.
Ifkeydoes not exist, OK will be returned without changes to the database. - See Also:
- valkey.io for details.
-
llen
public <ArgType> T llen(@NonNull ArgType key)
Returns the length of the list stored atkey.- Parameters:
key- The key of the list.- Returns:
- Command Response - The length of the list at
key.
Ifkeydoes not exist, it is interpreted as an empty list and0is returned. - See Also:
- valkey.io for details.
-
lrem
public <ArgType> T lrem(@NonNull ArgType key, long count, @NonNull ArgType element)
Removes the firstcountoccurrences of elements equal toelementfrom the list stored atkey.- Parameters:
key- The key of the list.count- The count of the occurrences of elements equal toelementto remove. Ifcountis positive: Removes elements equal toelementmoving from head to tail.
Ifcountis negative: Removes elements equal toelementmoving from tail to head.
Ifcountis 0 orcountis greater than the occurrences of elements equal toelement, it removes all elements equal toelement.element- The element to remove from the list.- Returns:
- Command Response - The number of the removed elements.
Ifkeydoes not exist,0is returned. - See Also:
- valkey.io for details.
-
rpush
public <ArgType> T rpush(@NonNull ArgType key, @NonNull @NonNull ArgType[] elements)
Inserts all the specified values at the tail of the list stored atkey.
elementsare inserted one after the other to the tail of the list, from the leftmost element to the rightmost element. Ifkeydoes not exist, it is created as an 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 atkey.- Returns:
- Command Response - The length of the list after the push operations.
- See Also:
- valkey.io for details.
-
rpop
public <ArgType> T rpop(@NonNull ArgType key)
Removes and returns the last elements of the list stored atkey.
The command pops a single element from the end of the list.- Parameters:
key- The key of the list.- Returns:
- Command Response - The value of the last element.
Ifkeydoes not exist,nullwill be returned. - See Also:
- valkey.io for details.
-
rpopCount
public <ArgType> T rpopCount(@NonNull ArgType key, long count)
Removes and returns up tocountelements from the list stored atkey, depending on the list's length.- Parameters:
count- The count of the elements to pop from the list.- Returns:
- Command Response - An array of popped elements will be returned depending on the list's
length.
Ifkeydoes not exist,nullwill be returned. - See Also:
- valkey.io for details.
-
sadd
public <ArgType> T sadd(@NonNull ArgType key, @NonNull @NonNull ArgType[] members)
Adds specified members to the set stored atkey. Specified members that are already a member of this set are ignored.- Parameters:
key- Thekeywhere members will be added to its set.members- A list of members to add to the set stored atkey.- Returns:
- Command Response - The number of members that were added to the set, excluding members already present.
- See Also:
- valkey.io for details.
-
sismember
public <ArgType> T sismember(@NonNull ArgType key, @NonNull ArgType member)
Returns ifmemberis a member of the set stored atkey.- Parameters:
key- The key of the set.member- The member to check for existence in the set.- Returns:
- Command Response -
trueif the member exists in the set,falseotherwise. Ifkeydoesn't exist, it is treated as anempty setand the command returnsfalse. - See Also:
- valkey.io for details.
-
srem
public <ArgType> T srem(@NonNull ArgType key, @NonNull @NonNull ArgType[] members)
Removes specified members from the set stored atkey. Specified members that are not a member of this set are ignored.- Parameters:
key- Thekeyfrom which members will be removed.members- A list of members to remove from the set stored atkey.- Returns:
- Command Response - The number of members that were removed from the set, excluding non-existing members.
- See Also:
- valkey.io for details.
-
smembers
public <ArgType> T smembers(@NonNull ArgType key)
Retrieves all the members of the set value stored atkey.- Parameters:
key- The key from which to retrieve the set members.- Returns:
- Command Response - A
Setof all members of the set. - See Also:
- valkey.io for details.
-
scard
public <ArgType> T scard(@NonNull ArgType key)
Retrieves the set cardinality (number of elements) of the set stored atkey.- Parameters:
key- The key from which to retrieve the number of set members.- Returns:
- Command Response - The cardinality (number of elements) of the set, or 0 if the key does not exist.
- See Also:
- valkey.io for details.
-
sdiff
public <ArgType> T sdiff(@NonNull @NonNull ArgType[] keys)
Computes the difference between the first set and all the successive sets inkeys.- Parameters:
keys- The keys of the sets to diff.- Returns:
- Command Response - A
Setof elements representing the difference between the sets.
If the akeydoes not exist, it is treated as an empty set. - See Also:
- valkey.io for details.
-
smismember
public <ArgType> T smismember(@NonNull ArgType key, @NonNull @NonNull ArgType[] members)
Checks whether each member is contained in the members of the set stored atkey.- Parameters:
key- The key of the set to check.members- A list of members to check for existence in the set.- Returns:
- Command Response - An
arrayofBooleanvalues, each indicating if the respective member exists in the set. - See Also:
- valkey.io for details.
-
sdiffstore
public <ArgType> T sdiffstore(@NonNull ArgType destination, @NonNull @NonNull ArgType[] keys)
Stores the difference between the first set and all the successive sets inkeysinto a new set atdestination.- Parameters:
destination- The key of the destination set.keys- The keys of the sets to diff.- Returns:
- Command Response - The number of elements in the resulting set.
- See Also:
- valkey.io for details.
-
smove
public <ArgType> T smove(@NonNull ArgType source, @NonNull ArgType destination, @NonNull ArgType member)
Movesmemberfrom the set atsourceto the set atdestination, 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.- Returns:
- Command response -
trueon success, orfalseif thesourceset does not exist or the element is not a member of the source set. - See Also:
- valkey.io for details.
-
sinter
public <ArgType> T sinter(@NonNull @NonNull ArgType[] keys)
Gets the intersection of all the given sets.- Parameters:
keys- The keys of the sets.- Returns:
- Command Response - A
Setof members which are present in all given sets.
Missing or empty input sets cause an empty response. - See Also:
- valkey.io for details.
-
sinterstore
public <ArgType> T sinterstore(@NonNull ArgType destination, @NonNull @NonNull ArgType[] keys)
Stores the members of the intersection of all given sets specified bykeysinto a new set atdestination.- Parameters:
destination- The key of the destination set.keys- The keys from which to retrieve the set members.- Returns:
- Command Response - The number of elements in the resulting set.
- See Also:
- valkey.io for details.
-
sintercard
public <ArgType> T sintercard(@NonNull @NonNull ArgType[] keys)
Gets the cardinality of the intersection of all the given sets.- Parameters:
keys- The keys of the sets.- Returns:
- Command Response - The cardinality of the intersection result. If one or more sets do
not exist,
0is returned. - Since:
- Valkey 7.0 and above.
- See Also:
- valkey.io for details.
-
sintercard
public <ArgType> T sintercard(@NonNull @NonNull ArgType[] keys, long limit)
Gets the cardinality of the intersection of all the given sets.- Parameters:
keys- The keys of the sets.limit- The limit for the intersection cardinality value.- Returns:
- Command Response - The cardinality of the intersection result. If one or more sets do
not exist,
0is returned. If the intersection cardinality reacheslimitpartway through the computation, returnslimitas the cardinality. - Since:
- Valkey 7.0 and above.
- See Also:
- valkey.io for details.
-
sunionstore
public <ArgType> T sunionstore(@NonNull ArgType destination, @NonNull @NonNull ArgType[] keys)
Stores the members of the union of all given sets specified bykeysinto a new set atdestination.- Parameters:
destination- The key of the destination set.keys- The keys from which to retrieve the set members.- Returns:
- Command Response - The number of elements in the resulting set.
- See Also:
- valkey.io for details.
-
configGet
public <ArgType> T configGet(@NonNull @NonNull ArgType[] parameters)
Reads the configuration parameters of the running server.
Starting from server version 7, command supports multiple parameters.- Parameters:
parameters- Anarrayof configuration parameter names to retrieve values for.- Returns:
- Command response - A
mapof values corresponding to the configuration parameters. - See Also:
- valkey.io for details.
-
configSet
public <ArgType> T configSet(@NonNull @NonNull java.util.Map<ArgType,ArgType> parameters)
Sets configuration parameters to the specified values.
Starting from server version 7, command supports multiple parameters.- Parameters:
parameters- Amapconsisting of configuration parameters and their respective values to set.- Returns:
- Command Response -
"OK"response on success. - See Also:
- valkey.io for details.
-
exists
public <ArgType> T exists(@NonNull @NonNull ArgType[] keys)
Returns the number of keys inkeysthat exist in the database.- Parameters:
keys- The keys list to check.- Returns:
- Command Response - The number of keys that exist. If the same existing key is mentioned
in
keysmultiple times, it will be counted multiple times. - See Also:
- valkey.io for details.
-
unlink
public <ArgType> T unlink(@NonNull @NonNull ArgType[] keys)
Unlinks (deletes) multiplekeysfrom the database. 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 list of keys to unlink.- Returns:
- Command Response - The number of
keysthat were unlinked. - See Also:
- valkey.io for details.
-
expire
public <ArgType> T expire(@NonNull ArgType key, long seconds)
Sets a timeout onkeyin seconds. After the timeout has expired, thekeywill automatically be deleted.
Ifkeyalready has an existingexpireset, the time to live is updated to the new value.
Ifsecondsis a non-positive number, thekeywill be deleted rather than expired.
The timeout will only be cleared by commands that delete or overwrite the contents ofkey.- Parameters:
key- The key to set timeout on it.seconds- The timeout in seconds.- Returns:
- Command response -
trueif the timeout was set.falseif the timeout was not set. e.g. key doesn't exist. - See Also:
- valkey.io for details.
-
expire
public <ArgType> T expire(@NonNull ArgType key, long seconds, @NonNull @NonNull ExpireOptions expireOptions)
Sets a timeout onkeyin seconds. After the timeout has expired, thekeywill automatically be deleted.
Ifkeyalready has an existingexpireset, the time to live is updated to the new value.
Ifsecondsis a non-positive number, thekeywill be deleted rather than expired.
The timeout will only be cleared by commands that delete or overwrite the contents ofkey.- Parameters:
key- The key to set timeout on it.seconds- The timeout in seconds.expireOptions- The expire options.- Returns:
- Command response -
trueif the timeout was set.falseif the timeout was not set. e.g.keydoesn't exist, or operation skipped due to the provided arguments. - See Also:
- valkey.io for details.
-
expireAt
public <ArgType> T expireAt(@NonNull ArgType key, long unixSeconds)
Sets a timeout onkey. 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 thekeyimmediately. After the timeout has expired, thekeywill automatically be deleted.
Ifkeyalready has an existingexpireset, the time to live is updated to the new value.
The timeout will only be cleared by commands that delete or overwrite the contents ofkey.- Parameters:
key- The key to set timeout on it.unixSeconds- The timeout in an absolute Unix timestamp.- Returns:
- Command response -
trueif the timeout was set.falseif the timeout was not set. e.g.keydoesn't exist. - See Also:
- valkey.io for details.
-
expireAt
public <ArgType> T expireAt(@NonNull ArgType key, long unixSeconds, @NonNull @NonNull ExpireOptions expireOptions)
Sets a timeout onkey. 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 thekeyimmediately. After the timeout has expired, thekeywill automatically be deleted.
Ifkeyalready has an existingexpireset, the time to live is updated to the new value.
The timeout will only be cleared by commands that delete or overwrite the contents ofkey.- Parameters:
key- The key to set timeout on it.unixSeconds- The timeout in an absolute Unix timestamp.expireOptions- The expire options.- Returns:
- Command response -
trueif the timeout was set.falseif the timeout was not set. e.g.keydoesn't exist, or operation skipped due to the provided arguments. - See Also:
- valkey.io for details.
-
pexpire
public <ArgType> T pexpire(@NonNull ArgType key, long milliseconds)
Sets a timeout onkeyin milliseconds. After the timeout has expired, thekeywill automatically be deleted.
Ifkeyalready has an existingexpireset, the time to live is updated to the new value.
Ifmillisecondsis a non-positive number, thekeywill be deleted rather than expired.
The timeout will only be cleared by commands that delete or overwrite the contents ofkey.- Parameters:
key- The key to set timeout on it.milliseconds- The timeout in milliseconds.- Returns:
- Command response -
trueif the timeout was set.falseif the timeout was not set. e.g.keydoesn't exist. - See Also:
- valkey.io for details.
-
pexpire
public <ArgType> T pexpire(@NonNull ArgType key, long milliseconds, @NonNull @NonNull ExpireOptions expireOptions)
Sets a timeout onkeyin milliseconds. After the timeout has expired, thekeywill automatically be deleted.
Ifkeyalready has an existing expire set, the time to live is updated to the new value.
Ifmillisecondsis a non-positive number, thekeywill be deleted rather than expired.
The timeout will only be cleared by commands that delete or overwrite the contents ofkey.- Parameters:
key- The key to set timeout on it.milliseconds- The timeout in milliseconds.expireOptions- The expire options.- Returns:
- Command response -
trueif the timeout was set.falseif the timeout was not set. e.g.keydoesn't exist, or operation skipped due to the provided arguments. - See Also:
- valkey.io for details.
-
pexpireAt
public <ArgType> T pexpireAt(@NonNull ArgType key, long unixMilliseconds)
Sets a timeout onkey. 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 thekeyimmediately. After the timeout has expired, thekeywill automatically be deleted.
Ifkeyalready has an existingexpireset, the time to live is updated to the new value.
The timeout will only be cleared by commands that delete or overwrite the contents ofkey.- Parameters:
key- Thekeyto set timeout on it.unixMilliseconds- The timeout in an absolute Unix timestamp.- Returns:
- Command response -
trueif the timeout was set.falseif the timeout was not set. e.g.keydoesn't exist. - See Also:
- valkey.io for details.
-
pexpireAt
public <ArgType> T pexpireAt(@NonNull ArgType key, long unixMilliseconds, @NonNull @NonNull ExpireOptions expireOptions)
Sets a timeout onkey. 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 thekeyimmediately. After the timeout has expired, thekeywill automatically be deleted.
Ifkeyalready has an existingexpireset, the time to live is updated to the new value.
The timeout will only be cleared by commands that delete or overwrite the contents ofkey.- Parameters:
key- Thekeyto set timeout on it.unixMilliseconds- The timeout in an absolute Unix timestamp.expireOptions- The expiration option.- Returns:
- Command response -
trueif the timeout was set.falseif the timeout was not set. e.g.keydoesn't exist, or operation skipped due to the provided arguments. - See Also:
- valkey.io for details.
-
ttl
public <ArgType> T ttl(@NonNull ArgType key)
Returns the remaining time to live ofkeythat has a timeout.- Parameters:
key- Thekeyto return its timeout.- Returns:
- Command response - TTL in seconds,
-2ifkeydoes not exist, or-1ifkeyexists but has no associated expire. - See Also:
- valkey.io for details.
-
expiretime
public <ArgType> T expiretime(@NonNull ArgType key)
Returns the absolute Unix timestamp (since January 1, 1970) at which the givenkeywill expire, in seconds.
To get the expiration with millisecond precision, use#pexpiretime(ArgType).- Parameters:
key- Thekeyto determine the expiration value of.- Returns:
- Command response - The expiration Unix timestamp in seconds,
-2ifkeydoes not exist, or-1ifkeyexists but has no associated expiration. - Since:
- Valkey 7.0 and above.
- See Also:
- valkey.io for details.
-
pexpiretime
public <ArgType> T pexpiretime(@NonNull ArgType key)
Returns the absolute Unix timestamp (since January 1, 1970) at which the givenkeywill expire, in milliseconds.- Parameters:
key- Thekeyto determine the expiration value of.- Returns:
- Command response - The expiration Unix timestamp in milliseconds,
-2ifkeydoes not exist, or-1ifkeyexists but has no associated expiration. - Since:
- Valkey 7.0 and above.
- See Also:
- valkey.io for details.
-
clientId
public T clientId()
Gets the current connection id.- Returns:
- Command response - The id of the client.
- See Also:
- valkey.io for details.
-
clientGetName
public T clientGetName()
Gets the name of the current connection.- Returns:
- Command response - The name of the client connection as a string if a name is set, or
nullif no name is assigned. - See Also:
- valkey.io for details.
-
clientPause
public T clientPause(long timeout)
Suspends all clients for the specified timeout.- Parameters:
timeout- The time in milliseconds to pause clients.- Returns:
- Command Response -
"OK"on success. - See Also:
- valkey.io for details.
-
clientPause
public T clientPause(long timeout, @NonNull @NonNull ClientPauseMode mode)
Suspends all clients for the specified timeout.- Parameters:
timeout- The time in milliseconds to pause clients.mode- The pause mode to use.- Returns:
- Command Response -
"OK"on success. - See Also:
- valkey.io for details.
-
clientUnpause
public T clientUnpause()
Resumes processing commands on all clients.- Returns:
- Command Response -
"OK"on success. - See Also:
- valkey.io for details.
-
configRewrite
public T configRewrite()
Rewrites the configuration file with the current configuration.- Returns:
- Command Response -
"OK"response on success. - See Also:
- valkey.io for details.
-
configResetStat
public T configResetStat()
Resets the statistics reported by the server using the INFO and LATENCY HISTOGRAM commands.- Returns:
- Command Response -
"OK"response on success. - See Also:
- valkey.io for details.
-
zadd
public <ArgType> T zadd(@NonNull ArgType key, @NonNull @NonNull java.util.Map<ArgType,java.lang.Double> membersScoresMap, @NonNull @NonNull ZAddOptions options, boolean changed)
Adds members with their scores to the sorted set stored atkey.
If a member is already a part of the sorted set, its score is updated.- Parameters:
key- The key of the sorted set.membersScoresMap- AMapof members to their corresponding scores.options- The ZAdd options.changed- Modify the return value from the number of new elements added, to the total number of elements changed.- Returns:
- Command Response - The number of elements added to the sorted set.
Ifchangedis set, returns the number of elements updated in the sorted set. - See Also:
- valkey.io for more details.
-
zadd
public <ArgType> T zadd(@NonNull ArgType key, @NonNull @NonNull java.util.Map<ArgType,java.lang.Double> membersScoresMap, @NonNull @NonNull ZAddOptions options)
Adds members with their scores to the sorted set stored atkey.
If a member is already a part of the sorted set, its score is updated.- Parameters:
key- The key of the sorted set.membersScoresMap- AMapof members to their corresponding scores.options- The ZAdd options.- Returns:
- Command Response - The number of elements added to the sorted set.
- See Also:
- valkey.io for more details.
-
zadd
public <ArgType> T zadd(@NonNull ArgType key, @NonNull @NonNull java.util.Map<ArgType,java.lang.Double> membersScoresMap, boolean changed)
Adds members with their scores to the sorted set stored atkey.
If a member is already a part of the sorted set, its score is updated.- Parameters:
key- The key of the sorted set.membersScoresMap- AMapof members to their corresponding scores.changed- Modify the return value from the number of new elements added, to the total number of elements changed.- Returns:
- Command Response - The number of elements added to the sorted set.
Ifchangedis set, returns the number of elements updated in the sorted set. - See Also:
- valkey.io for more details.
-
zadd
public <ArgType> T zadd(@NonNull ArgType key, @NonNull @NonNull java.util.Map<ArgType,java.lang.Double> membersScoresMap)
Adds members with their scores to the sorted set stored atkey.
If a member is already a part of the sorted set, its score is updated.- Parameters:
key- The key of the sorted set.membersScoresMap- AMapof members to their corresponding scores.- Returns:
- Command Response - The number of elements added to the sorted set.
- See Also:
- valkey.io for more details.
-
zaddIncr
public <ArgType> T zaddIncr(@NonNull ArgType key, @NonNull ArgType member, double increment, @NonNull @NonNull ZAddOptions options)
Increments the score of member in the sorted set stored atkeybyincrement.
Ifmemberdoes not exist in the sorted set, it is added withincrementas its score (as if its previous score was 0.0).
Ifkeydoes not exist, a new sorted set with the specified member as its sole member is created.
zaddIncrwith empty option acts as#zincrby(ArgType, double, ArgType).- Parameters:
key- The key of the sorted set.member- A member in the sorted set to increment.increment- The score to increment the member.options- The ZAdd options.- Returns:
- Command Response - The score of the member.
If there was a conflict with the options, the operation aborts andnullis returned. - See Also:
- valkey.io for more details.
-
zaddIncr
public <ArgType> T zaddIncr(@NonNull ArgType key, @NonNull ArgType member, double increment)
Increments the score of member in the sorted set stored atkeybyincrement.
Ifmemberdoes not exist in the sorted set, it is added withincrementas its score (as if its previous score was 0.0).
Ifkeydoes 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- The score to increment the member.- Returns:
- Command Response - The score of the member.
- See Also:
- valkey.io for more details.
-
zrem
public <ArgType> T zrem(@NonNull ArgType key, @NonNull @NonNull ArgType[] members)
Removes the specified members from the sorted set stored atkey.
Specified members that are not a member of this set are ignored.- Parameters:
key- The key of the sorted set.members- An array of members to remove from the sorted set.- Returns:
- Command Response - The number of members that were removed from the sorted set, not
including non-existing members.
Ifkeydoes not exist, it is treated as an empty sorted set, and this command returns0. - See Also:
- valkey.io for more details.
-
zcard
public <ArgType> T zcard(@NonNull ArgType key)
Returns the cardinality (number of elements) of the sorted set stored atkey.- Parameters:
key- The key of the sorted set.- Returns:
- Command Response - The number of elements in the sorted set.
Ifkeydoes not exist, it is treated as an empty sorted set, and this command return0. - See Also:
- valkey.io for more details.
-
zpopmin
public <ArgType> T zpopmin(@NonNull ArgType key, long count)
Removes and returns up tocountmembers with the lowest scores from the sorted set stored at the specifiedkey.- Parameters:
key- The key of the sorted set.count- Specifies the quantity of members to pop.
Ifcountis higher than the sorted set's cardinality, returns all members and their scores, ordered from lowest to highest.- Returns:
- Command Response - A map of the removed members and their scores, ordered from the one
with the lowest score to the one with the highest.
Ifkeydoesn't exist, it will be treated as an empty sorted set and the command returns an emptyMap. - See Also:
- valkey.io for more details.
-
zpopmin
public <ArgType> T zpopmin(@NonNull ArgType key)
Removes and returns the member with the lowest score from the sorted set stored at the specifiedkey.- Parameters:
key- The key of the sorted set.- Returns:
- Command Response - A map containing the removed member and its corresponding score.
Ifkeydoesn't exist, it will be treated as an empty sorted set and the command returns an emptyMap. - See Also:
- valkey.io for more details.
-
zrandmember
public <ArgType> T zrandmember(@NonNull ArgType key)
Returns a random element from the sorted set stored atkey.- Parameters:
key- The key of the sorted set.- Returns:
- Command Response - A
Stringrepresenting a random element from the sorted set.
If the sorted set does not exist or is empty, the response will benull. - See Also:
- valkey.io for more details.
-
zrandmemberWithCount
public <ArgType> T zrandmemberWithCount(@NonNull ArgType key, long count)
Retrieves random elements from the sorted set stored atkey.- Parameters:
key- The key of the sorted set.count- The number of elements to return.
Ifcountis positive, returns unique elements.
If negative, allows for duplicates.- Returns:
- Command Response - An
arrayof elements from the sorted set.
If the sorted set does not exist or is empty, the response will be an emptyarray. - See Also:
- valkey.io for more details.
-
zrandmemberWithCountWithScores
public <ArgType> T zrandmemberWithCountWithScores(ArgType key, long count)
Retrieves random elements along with their scores from the sorted set stored atkey.- Parameters:
key- The key of the sorted set.count- The number of elements to return.
Ifcountis positive, returns unique elements.
If negative, allows duplicates.- Returns:
- Command Response - An
arrayof[element, score]arrays, where element is aStringand score is aDouble.
If the sorted set does not exist or is empty, the response will be an emptyarray. - See Also:
- valkey.io for more details.
-
zincrby
public <ArgType> T zincrby(@NonNull ArgType key, double increment, @NonNull ArgType member)
Increments the score ofmemberin the sorted set stored atkeybyincrement.
Ifmemberdoes not exist in the sorted set, it is added withincrementas its score. Ifkeydoes not exist, a new sorted set with the specified member as its sole member is created.- Parameters:
key- The key of the sorted set.increment- The score increment.member- A member of the sorted set.- Returns:
- Command Response - The new score of
member. - See Also:
- valkey.io for more details.
-
bzpopmin
public <ArgType> T bzpopmin(@NonNull @NonNull ArgType[] keys, double timeout)
Blocks the connection until it removes and returns a member with the lowest score from the sorted sets stored at the specifiedkeys. The sorted sets are checked in the order they are provided.
BZPOPMINis the blocking variant of#zpopmin(ArgType).- Parameters:
keys- The keys of the sorted sets.timeout- The number of seconds to wait for a blocking operation to complete. A value of0will block indefinitely.- Returns:
- Command Response - An
arraycontaining the key where the member was popped out, the member itself, and the member score.
If no member could be popped and thetimeoutexpired, returnsnull. - See Also:
- valkey.io for more details.
-
zpopmax
public <ArgType> T zpopmax(@NonNull ArgType key, long count)
Removes and returns up tocountmembers with the highest scores from the sorted set stored at the specifiedkey.- Parameters:
key- The key of the sorted set.count- Specifies the quantity of members to pop.
Ifcountis higher than the sorted set's cardinality, returns all members and their scores, ordered from highest to lowest.- Returns:
- Command Response - A map of the removed members and their scores, ordered from the one
with the highest score to the one with the lowest.
Ifkeydoesn't exist, it will be treated as an empty sorted set and the command returns an emptyMap. - See Also:
- valkey.io for more details.
-
zpopmax
public <ArgType> T zpopmax(@NonNull ArgType key)
Removes and returns the member with the highest score from the sorted set stored at the specifiedkey.- Parameters:
key- The key of the sorted set.- Returns:
- Command Response - A map containing the removed member and its corresponding score.
Ifkeydoesn't exist, it will be treated as an empty sorted set and the command returns an emptyMap. - See Also:
- valkey.io for more details.
-
bzpopmax
public <ArgType> T bzpopmax(@NonNull @NonNull ArgType[] keys, double timeout)
Blocks the connection until it removes and returns a member with the highest score from the sorted sets stored at the specifiedkeys. The sorted sets are checked in the order they are provided.
BZPOPMAXis the blocking variant of#zpopmax(ArgType).- Parameters:
keys- The keys of the sorted sets.timeout- The number of seconds to wait for a blocking operation to complete. A value of0will block indefinitely.- Returns:
- Command Response - An
arraycontaining the key where the member was popped out, the member itself, and the member score.
If no member could be popped and thetimeoutexpired, returnsnull. - See Also:
- valkey.io for more details.
-
zscore
public <ArgType> T zscore(@NonNull ArgType key, @NonNull ArgType member)
Returns the score ofmemberin the sorted set stored atkey.- Parameters:
key- The key of the sorted set.member- The member whose score is to be retrieved.- Returns:
- Command Response - The score of the member.
Ifmemberdoes not exist in the sorted set,nullis returned.
Ifkeydoes not exist,nullis returned. - See Also:
- valkey.io for more details.
-
zrank
public <ArgType> T zrank(@NonNull ArgType key, @NonNull ArgType member)
Returns the rank ofmemberin the sorted set stored atkey, with scores ordered from low to high, starting from0.
To get the rank ofmemberwith its score, seezrankWithScore(ArgType, ArgType).- Parameters:
key- The key of the sorted set.member- The member whose rank is to be retrieved.- Returns:
- Command Response - The rank of
memberin the sorted set.
Ifkeydoesn't exist, or ifmemberis not present in the set,nullwill be returned. - See Also:
- valkey.io for more details.
-
zrankWithScore
public <ArgType> T zrankWithScore(@NonNull ArgType key, @NonNull ArgType member)
Returns the rank ofmemberin the sorted set stored atkeywith its score, where scores are ordered from the lowest to highest, starting from0.- Parameters:
key- The key of the sorted set.member- The member whose rank is to be retrieved.- Returns:
- Command Response - An
arraycontaining the rank (asLong) and score (asDouble) ofmemberin the sorted set.
Ifkeydoesn't exist, or ifmemberis not present in the set,nullwill be returned. - Since:
- Valkey 7.2.0 and above.
- See Also:
- valkey.io for more details.
-
zrevrank
public <ArgType> T zrevrank(@NonNull ArgType key, @NonNull ArgType member)
Returns the rank ofmemberin the sorted set stored atkey, where scores are ordered from the highest to lowest, starting from0.
To get the rank ofmemberwith its score, seezrevrankWithScore(ArgType, ArgType).- Parameters:
key- The key of the sorted set.member- The member whose rank is to be retrieved.- Returns:
- Command Response - The rank of
memberin the sorted set, where ranks are ordered from high to low based on scores.
Ifkeydoesn't exist, or ifmemberis not present in the set,nullwill be returned. - See Also:
- valkey.io for more details.
-
zrevrankWithScore
public <ArgType> T zrevrankWithScore(@NonNull ArgType key, @NonNull ArgType member)
Returns the rank ofmemberin the sorted set stored atkeywith its score, where scores are ordered from the highest to lowest, starting from0.- Parameters:
key- The key of the sorted set.member- The member whose rank is to be retrieved.- Returns:
- Command Response - An
arraycontaining the rank (asLong) and score (asDouble) ofmemberin the sorted set, where ranks are ordered from high to low based on scores.
Ifkeydoesn't exist, or ifmemberis not present in the set,nullwill be returned. - Since:
- Valkey 7.2.0 and above.
- See Also:
- valkey.io for more details.
-
zmscore
public <ArgType> T zmscore(@NonNull ArgType key, @NonNull @NonNull ArgType[] members)
Returns the scores associated with the specifiedmembersin the sorted set stored atkey.- Parameters:
key- The key of the sorted set.members- An array of members in the sorted set.- Returns:
- Command Response - An
Arrayof scores of themembers.
If amemberdoes not exist, the corresponding value in theArraywill benull. - See Also:
- valkey.io for more details.
-
zdiff
public <ArgType> T zdiff(@NonNull @NonNull ArgType[] keys)
Returns the difference between the first sorted set and all the successive sorted sets.
To get the elements with their scores, seezdiffWithScores(ArgType[]).- Parameters:
keys- The keys of the sorted sets.- Returns:
- Command Response - An
arrayof elements representing the difference between the sorted sets.
If the firstkeydoes not exist, it is treated as an empty sorted set, and the command returns an emptyarray. - Since:
- Valkey 6.2 and above.
- See Also:
- valkey.io for more details.
-
zdiffWithScores
public <ArgType> T zdiffWithScores(@NonNull @NonNull ArgType[] keys)
Returns the difference between the first sorted set and all the successive sorted sets.- Parameters:
keys- The keys of the sorted sets.- Returns:
- Command Response - A
Mapof elements and their scores representing the difference between the sorted sets.
If the firstkeydoes not exist, it is treated as an empty sorted set, and the command returns an emptyMap. - Since:
- Valkey 6.2 and above.
- See Also:
- valkey.io for more details.
-
zdiffstore
public <ArgType> T zdiffstore(@NonNull ArgType destination, @NonNull @NonNull ArgType[] keys)
Calculates the difference between the first sorted set and all the successive sorted sets atkeysand stores the difference as a sorted set todestination, 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.- Returns:
- Command Response - The number of members in the resulting sorted set stored at
destination. - Since:
- Valkey 6.2 and above.
- See Also:
- valkey.io for more details.
-
zcount
public <ArgType> T zcount(@NonNull ArgType key, @NonNull @NonNull RangeOptions.ScoreRange minScore, @NonNull @NonNull RangeOptions.ScoreRange maxScore)
Returns the number of members in the sorted set stored atkeywith scores betweenminScoreandmaxScore.- Parameters:
key- The key of the sorted set.minScore- The minimum score to count from. Can be an implementation ofRangeOptions.InfScoreBoundrepresenting positive/negative infinity, orRangeOptions.ScoreBoundaryrepresenting a specific score and inclusivity.maxScore- The maximum score to count up to. Can be an implementation ofRangeOptions.InfScoreBoundrepresenting positive/negative infinity, orRangeOptions.ScoreBoundaryrepresenting a specific score and inclusivity.- Returns:
- Command Response - The number of members in the specified score range.
Ifkeydoes not exist, it is treated as an empty sorted set, and the command returns0.
IfmaxScore < minScore,0is returned. - See Also:
- valkey.io for more details.
-
zremrangebyrank
public <ArgType> T zremrangebyrank(@NonNull ArgType key, long start, long end)
Removes all elements in the sorted set stored atkeywith rank betweenstartandend. Bothstartandendare zero-based indexes with0being 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- The starting point of the range.end- The end of the range.- Returns:
- Command Response - The number of elements removed.
Ifstartexceeds the end of the sorted set, or ifstartis greater thanend,0returned.
Ifendexceeds the actual end of the sorted set, the range will stop at the actual end of the sorted set.
Ifkeydoes not exist0will be returned. - See Also:
- valkey.io for more details.
-
zrangestore
public <ArgType> T zrangestore(@NonNull ArgType destination, @NonNull ArgType source, @NonNull @NonNull RangeOptions.RangeQuery rangeQuery, boolean reverse)
Stores a specified range of elements from the sorted set atsource, into a new sorted set atdestination. Ifdestinationdoesn'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
RangeOptions.RangeByIndex. - For range queries by lexicographical order, use
RangeOptions.RangeByLex. - For range queries by score, use
RangeOptions.RangeByScore.
- For range queries by index (rank), use
reverse- Iftrue, reverses the sorted set, with index0as the element with the highest score.- Returns:
- Command Response - The number of elements in the resulting sorted set.
- See Also:
- valkey.io for more details.
-
zrangestore
public <ArgType> T zrangestore(@NonNull ArgType destination, @NonNull ArgType source, @NonNull @NonNull RangeOptions.RangeQuery rangeQuery)
Stores a specified range of elements from the sorted set atsource, into a new sorted set atdestination. Ifdestinationdoesn'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
RangeOptions.RangeByIndex. - For range queries by lexicographical order, use
RangeOptions.RangeByLex. - For range queries by score, use
RangeOptions.RangeByScore.
- For range queries by index (rank), use
- Returns:
- Command Response - The number of elements in the resulting sorted set.
- See Also:
- valkey.io for more details.
-
zremrangebylex
public <ArgType> T zremrangebylex(@NonNull ArgType key, @NonNull @NonNull RangeOptions.LexRange minLex, @NonNull @NonNull RangeOptions.LexRange maxLex)
Removes all elements in the sorted set stored atkeywith a lexicographical order betweenminLexandmaxLex.- Parameters:
key- The key of the sorted set.minLex- The minimum bound of the lexicographical range. Can be an implementation ofRangeOptions.InfLexBoundrepresenting positive/negative infinity, orRangeOptions.LexBoundaryrepresenting a specific lex and inclusivity.maxLex- The maximum bound of the lexicographical range. Can be an implementation ofRangeOptions.InfLexBoundrepresenting positive/negative infinity, orRangeOptions.LexBoundaryrepresenting a specific lex and inclusivity.- Returns:
- Command Response - The number of members removed from the sorted set.
Ifkeydoes not exist, it is treated as an empty sorted set, and the command returns0.
IfminLexis greater thanmaxLex,0is returned. - See Also:
- valkey.io for more details.
-
zremrangebyscore
public <ArgType> T zremrangebyscore(@NonNull ArgType key, @NonNull @NonNull RangeOptions.ScoreRange minScore, @NonNull @NonNull RangeOptions.ScoreRange maxScore)
Removes all elements in the sorted set stored atkeywith a score betweenminScoreandmaxScore.- Parameters:
key- The key of the sorted set.minScore- The minimum score to remove from. Can be an implementation ofRangeOptions.InfScoreBoundrepresenting positive/negative infinity, orRangeOptions.ScoreBoundaryrepresenting a specific score and inclusivity.maxScore- The maximum score to remove to. Can be an implementation ofRangeOptions.InfScoreBoundrepresenting positive/negative infinity, orRangeOptions.ScoreBoundaryrepresenting a specific score and inclusivity.- Returns:
- Command Response - The number of members removed.
Ifkeydoes not exist, it is treated as an empty sorted set, and the command returns0.
IfminScoreis greater thanmaxScore,0is returned. - See Also:
- valkey.io for more details.
-
zlexcount
public <ArgType> T zlexcount(@NonNull ArgType key, @NonNull @NonNull RangeOptions.LexRange minLex, @NonNull @NonNull RangeOptions.LexRange maxLex)
Returns the number of members in the sorted set stored atkeywith scores betweenminLexandmaxLex.- Parameters:
key- The key of the sorted set.minLex- The minimum lex to count from. Can be an implementation ofRangeOptions.InfLexBoundrepresenting positive/negative infinity, orRangeOptions.LexBoundaryrepresenting a specific lex and inclusivity.maxLex- The maximum lex to count up to. Can be an implementation ofRangeOptions.InfLexBoundrepresenting positive/negative infinity, orRangeOptions.LexBoundaryrepresenting a specific lex and inclusivity.- Returns:
- Command Response - The number of members in the specified lex range.
Ifkeydoes not exist, it is treated as an empty sorted set, and the command returns0.
IfmaxLex < minLex,0is returned. - See Also:
- valkey.io for more details.
-
zunionstore
public T zunionstore(@NonNull @NonNull java.lang.String destination, @NonNull @NonNull WeightAggregateOptions.KeysOrWeightedKeys keysOrWeightedKeys, @NonNull @NonNull WeightAggregateOptions.Aggregate aggregate)
Computes the union of sorted sets given by the specifiedKeysOrWeightedKeys, and stores the result indestination. Ifdestinationalready exists, it is overwritten. Otherwise, a new sorted set will be created.- Parameters:
destination- The key of the destination sorted set.keysOrWeightedKeys- The keys of the sorted sets with possible formats:- Use
WeightAggregateOptions.KeyArrayfor keys only. - Use
WeightAggregateOptions.WeightedKeysfor weighted keys with score multipliers.
- Use
aggregate- Specifies the aggregation strategy to apply when combining the scores of elements.- Returns:
- Command Response - The number of elements in the resulting sorted set stored at
destination. - See Also:
- valkey.io for more details.
-
zunionstore
public T zunionstore(@NonNull @NonNull GlideString destination, @NonNull @NonNull WeightAggregateOptions.KeysOrWeightedKeysBinary keysOrWeightedKeys, @NonNull @NonNull WeightAggregateOptions.Aggregate aggregate)
Computes the union of sorted sets given by the specifiedKeysOrWeightedKeys, and stores the result indestination. Ifdestinationalready exists, it is overwritten. Otherwise, a new sorted set will be created.- Parameters:
destination- The key of the destination sorted set.keysOrWeightedKeys- The keys of the sorted sets with possible formats:- Use
WeightAggregateOptions.KeyArrayBinaryfor keys only. - Use
WeightAggregateOptions.WeightedKeysBinaryfor weighted keys with score multipliers.
- Use
aggregate- Specifies the aggregation strategy to apply when combining the scores of elements.- Returns:
- Command Response - The number of elements in the resulting sorted set stored at
destination. - See Also:
- valkey.io for more details.
-
zunionstore
public T zunionstore(@NonNull @NonNull java.lang.String destination, @NonNull @NonNull WeightAggregateOptions.KeysOrWeightedKeys keysOrWeightedKeys)
Computes the union of sorted sets given by the specifiedKeysOrWeightedKeys, and stores the result indestination. Ifdestinationalready exists, it is overwritten. Otherwise, a new sorted set will be created.- Parameters:
destination- The key of the destination sorted set.keysOrWeightedKeys- The keys of the sorted sets with possible formats:- Use
WeightAggregateOptions.KeyArrayfor keys only. - Use
WeightAggregateOptions.WeightedKeysfor weighted keys with score multipliers.
- Use
- Returns:
- Command Response - The number of elements in the resulting sorted set stored at
destination. - See Also:
- valkey.io for more details.
-
zunionstore
public T zunionstore(@NonNull @NonNull GlideString destination, @NonNull @NonNull WeightAggregateOptions.KeysOrWeightedKeysBinary keysOrWeightedKeys)
Computes the union of sorted sets given by the specifiedKeysOrWeightedKeys, and stores the result indestination. Ifdestinationalready exists, it is overwritten. Otherwise, a new sorted set will be created.- Parameters:
destination- The key of the destination sorted set.keysOrWeightedKeys- The keys of the sorted sets with possible formats:- Use
WeightAggregateOptions.KeyArrayBinaryfor keys only. - Use
WeightAggregateOptions.WeightedKeysBinaryfor weighted keys with score multipliers.
- Use
- Returns:
- Command Response - The number of elements in the resulting sorted set stored at
destination. - See Also:
- valkey.io for more details.
-
zinterstore
public T zinterstore(@NonNull @NonNull java.lang.String destination, @NonNull @NonNull WeightAggregateOptions.KeysOrWeightedKeys keysOrWeightedKeys, @NonNull @NonNull WeightAggregateOptions.Aggregate aggregate)
Computes the intersection of sorted sets given by the specifiedkeysOrWeightedKeys, and stores the result indestination. Ifdestinationalready exists, it is overwritten. Otherwise, a new sorted set will be created.- Parameters:
destination- The key of the destination sorted set.keysOrWeightedKeys- The keys of the sorted sets with possible formats:- Use
WeightAggregateOptions.KeyArrayfor keys only. - Use
WeightAggregateOptions.WeightedKeysfor weighted keys with score multipliers.
- Use
aggregate- Specifies the aggregation strategy to apply when combining the scores of elements.- Returns:
- Command Response - The number of elements in the resulting sorted set stored at
destination. - See Also:
- valkey.io for more details.
-
zinterstore
public T zinterstore(@NonNull @NonNull GlideString destination, @NonNull @NonNull WeightAggregateOptions.KeysOrWeightedKeysBinary keysOrWeightedKeys, @NonNull @NonNull WeightAggregateOptions.Aggregate aggregate)
Computes the intersection of sorted sets given by the specifiedkeysOrWeightedKeys, and stores the result indestination. Ifdestinationalready exists, it is overwritten. Otherwise, a new sorted set will be created.- Parameters:
destination- The key of the destination sorted set.keysOrWeightedKeys- The keys of the sorted sets with possible formats:- Use
WeightAggregateOptions.KeyArrayBinaryfor keys only. - Use
WeightAggregateOptions.WeightedKeysBinaryfor weighted keys with score multipliers.
- Use
aggregate- Specifies the aggregation strategy to apply when combining the scores of elements.- Returns:
- Command Response - The number of elements in the resulting sorted set stored at
destination. - See Also:
- valkey.io for more details.
-
zintercard
public <ArgType> T zintercard(@NonNull @NonNull ArgType[] keys)
Returns the cardinality of the intersection of the sorted sets specified bykeys.- Parameters:
keys- The keys of the sorted sets to intersect.- Returns:
- Command Response - The cardinality of the intersection of the given sorted sets.
- Since:
- Valkey 7.0 and above.
- See Also:
- valkey.io for more details.
-
zintercard
public <ArgType> T zintercard(@NonNull @NonNull ArgType[] keys, long limit)
Returns the cardinality of the intersection of the sorted sets specified bykeys. If the intersection cardinality reacheslimitpartway through the computation, the algorithm will exit early and yieldlimitas the cardinality.- Parameters:
keys- The keys of the sorted sets to intersect.limit- Specifies a maximum number for the intersection cardinality. If limit is set to0the range will be unlimited.- Returns:
- Command Response - The cardinality of the intersection of the given sorted sets, or the
limitif reached. - Since:
- Valkey 7.0 and above.
- See Also:
- valkey.io for more details.
-
zinterstore
public T zinterstore(@NonNull @NonNull java.lang.String destination, @NonNull @NonNull WeightAggregateOptions.KeysOrWeightedKeys keysOrWeightedKeys)
Computes the intersection of sorted sets given by the specifiedKeysOrWeightedKeys, and stores the result indestination. Ifdestinationalready exists, it is overwritten. Otherwise, a new sorted set will be created.
To perform azinterstoreoperation while specifying aggregation settings, usezinterstore(String, KeysOrWeightedKeys, Aggregate).- Parameters:
destination- The key of the destination sorted set.keysOrWeightedKeys- The keys of the sorted sets with possible formats:- Use
WeightAggregateOptions.KeyArrayfor keys only. - Use
WeightAggregateOptions.WeightedKeysfor weighted keys with score multipliers.
- Use
- Returns:
- Command Response - The number of elements in the resulting sorted set stored at
destination. - See Also:
- valkey.io for more details.
-
zinterstore
public T zinterstore(@NonNull @NonNull GlideString destination, @NonNull @NonNull WeightAggregateOptions.KeysOrWeightedKeysBinary keysOrWeightedKeys)
Computes the intersection of sorted sets given by the specifiedKeysOrWeightedKeys, and stores the result indestination. Ifdestinationalready exists, it is overwritten. Otherwise, a new sorted set will be created.
To perform azinterstoreoperation while specifying aggregation settings, usezinterstore(GlideString, KeysOrWeightedKeysBinary, Aggregate).- Parameters:
destination- The key of the destination sorted set.keysOrWeightedKeys- The keys of the sorted sets with possible formats:- Use
WeightAggregateOptions.KeyArrayBinaryfor keys only. - Use
WeightAggregateOptions.KeysOrWeightedKeysBinaryfor weighted keys with score multipliers.
- Use
- Returns:
- Command Response - The number of elements in the resulting sorted set stored at
destination. - See Also:
- valkey.io for more details.
-
zunion
public T zunion(@NonNull @NonNull WeightAggregateOptions.KeyArray keys)
Returns the union of members from sorted sets specified by the givenkeys.
To get the elements with their scores, seezunionWithScores(glide.api.models.commands.WeightAggregateOptions.KeysOrWeightedKeys, glide.api.models.commands.WeightAggregateOptions.Aggregate).- Parameters:
keys- The keys of the sorted sets.- Returns:
- Command Response - The resulting sorted set from the union.
- Since:
- Valkey 6.2 and above.
- See Also:
- valkey.io for more details.
-
zunion
public T zunion(@NonNull @NonNull WeightAggregateOptions.KeyArrayBinary keys)
Returns the union of members from sorted sets specified by the givenkeys.
To get the elements with their scores, seezunionWithScores(glide.api.models.commands.WeightAggregateOptions.KeysOrWeightedKeys, glide.api.models.commands.WeightAggregateOptions.Aggregate).- Parameters:
keys- The keys of the sorted sets.- Returns:
- Command Response - The resulting sorted set from the union.
- Since:
- Valkey 6.2 and above.
- See Also:
- valkey.io for more details.
-
zunionWithScores
public T zunionWithScores(@NonNull @NonNull WeightAggregateOptions.KeysOrWeightedKeys keysOrWeightedKeys, @NonNull @NonNull WeightAggregateOptions.Aggregate aggregate)
Returns the union of members and their scores from sorted sets specified by the givenkeysOrWeightedKeys.- Parameters:
keysOrWeightedKeys- The keys of the sorted sets with possible formats:- Use
WeightAggregateOptions.KeyArrayfor keys only. - Use
WeightAggregateOptions.WeightedKeysfor weighted keys with score multipliers.
- Use
aggregate- Specifies the aggregation strategy to apply when combining the scores of elements.- Returns:
- Command Response - The resulting sorted set from the union.
- Since:
- Valkey 6.2 and above.
- See Also:
- valkey.io for more details.
-
zunionWithScores
public T zunionWithScores(@NonNull @NonNull WeightAggregateOptions.KeysOrWeightedKeysBinary keysOrWeightedKeys, @NonNull @NonNull WeightAggregateOptions.Aggregate aggregate)
Returns the union of members and their scores from sorted sets specified by the givenkeysOrWeightedKeys.- Parameters:
keysOrWeightedKeys- The keys of the sorted sets with possible formats:- Use
WeightAggregateOptions.KeyArrayBinaryfor keys only. - Use
WeightAggregateOptions.WeightedKeysBinaryfor weighted keys with score multipliers.
- Use
aggregate- Specifies the aggregation strategy to apply when combining the scores of elements.- Returns:
- Command Response - The resulting sorted set from the union.
- Since:
- Valkey 6.2 and above.
- See Also:
- valkey.io for more details.
-
zunionWithScores
public T zunionWithScores(@NonNull @NonNull WeightAggregateOptions.KeysOrWeightedKeys keysOrWeightedKeys)
Returns the union of members and their scores from sorted sets specified by the givenkeysOrWeightedKeys.
To perform azunionoperation while specifying aggregation settings, usezunionWithScores(KeysOrWeightedKeys, Aggregate).- Parameters:
keysOrWeightedKeys- The keys of the sorted sets with possible formats:- Use
WeightAggregateOptions.KeyArrayfor keys only. - Use
WeightAggregateOptions.WeightedKeysfor weighted keys with score multipliers.
- Use
- Returns:
- Command Response - The resulting sorted set from the union.
- Since:
- Valkey 6.2 and above.
- See Also:
- valkey.io for more details.
-
zunionWithScores
public T zunionWithScores(@NonNull @NonNull WeightAggregateOptions.KeysOrWeightedKeysBinary keysOrWeightedKeys)
Returns the union of members and their scores from sorted sets specified by the givenkeysOrWeightedKeys.
To perform azunionoperation while specifying aggregation settings, usezunionWithScores(KeysOrWeightedKeys, Aggregate).- Parameters:
keysOrWeightedKeys- The keys of the sorted sets with possible formats:- Use
WeightAggregateOptions.KeyArrayBinaryfor keys only. - Use
WeightAggregateOptions.WeightedKeysBinaryfor weighted keys with score multipliers.
- Use
- Returns:
- Command Response - The resulting sorted set from the union.
- Since:
- Valkey 6.2 and above.
- See Also:
- valkey.io for more details.
-
zinter
public T zinter(@NonNull @NonNull WeightAggregateOptions.KeyArray keys)
Returns the intersection of members from sorted sets specified by the givenkeys.
To get the elements with their scores, seezinterWithScores(glide.api.models.commands.WeightAggregateOptions.KeysOrWeightedKeys).- Parameters:
keys- The keys of the sorted sets.- Returns:
- Command Response - The resulting sorted set from the intersection.
- Since:
- Valkey 6.2 and above.
- See Also:
- valkey.io for more details.
-
zinter
public T zinter(@NonNull @NonNull WeightAggregateOptions.KeyArrayBinary keys)
Returns the intersection of members from sorted sets specified by the givenkeys.
To get the elements with their scores, seezinterWithScores(glide.api.models.commands.WeightAggregateOptions.KeysOrWeightedKeys).- Parameters:
keys- The keys of the sorted sets.- Returns:
- Command Response - The resulting sorted set from the intersection.
- Since:
- Valkey 6.2 and above.
- See Also:
- valkey.io for more details.
-
zinterWithScores
public T zinterWithScores(@NonNull @NonNull WeightAggregateOptions.KeysOrWeightedKeys keysOrWeightedKeys)
Returns the intersection of members and their scores from sorted sets specified by the givenkeysOrWeightedKeys. To perform azinteroperation while specifying aggregation settings, usezinterWithScores(KeysOrWeightedKeys, Aggregate).- Parameters:
keysOrWeightedKeys- The keys of the sorted sets with possible formats:- Use
WeightAggregateOptions.KeyArrayfor keys only. - Use
WeightAggregateOptions.WeightedKeysfor weighted keys with score multipliers.
- Use
- Returns:
- Command Response - The resulting sorted set from the intersection.
- Since:
- Valkey 6.2 and above.
- See Also:
- valkey.io for more details.
-
zinterWithScores
public T zinterWithScores(@NonNull @NonNull WeightAggregateOptions.KeysOrWeightedKeysBinary keysOrWeightedKeys)
Returns the intersection of members and their scores from sorted sets specified by the givenkeysOrWeightedKeys. To perform azinteroperation while specifying aggregation settings, usezinterWithScores(KeysOrWeightedKeys, Aggregate).- Parameters:
keysOrWeightedKeys- The keys of the sorted sets with possible formats:- Use
WeightAggregateOptions.KeyArrayBinaryfor keys only. - Use
WeightAggregateOptions.WeightedKeysBinaryfor weighted keys with score multipliers.
- Use
- Returns:
- Command Response - The resulting sorted set from the intersection.
- Since:
- Valkey 6.2 and above.
- See Also:
- valkey.io for more details.
-
zinterWithScores
public T zinterWithScores(@NonNull @NonNull WeightAggregateOptions.KeysOrWeightedKeys keysOrWeightedKeys, @NonNull @NonNull WeightAggregateOptions.Aggregate aggregate)
Returns the intersection of members and their scores from sorted sets specified by the givenkeysOrWeightedKeys.- Parameters:
keysOrWeightedKeys- The keys of the sorted sets with possible formats:- Use
WeightAggregateOptions.KeyArrayfor keys only. - Use
WeightAggregateOptions.WeightedKeysfor weighted keys with score multipliers.
- Use
aggregate- Specifies the aggregation strategy to apply when combining the scores of elements.- Returns:
- Command Response - The resulting sorted set from the intersection.
- Since:
- Valkey 6.2 and above.
- See Also:
- valkey.io for more details.
-
zinterWithScores
public T zinterWithScores(@NonNull @NonNull WeightAggregateOptions.KeysOrWeightedKeysBinary keysOrWeightedKeys, @NonNull @NonNull WeightAggregateOptions.Aggregate aggregate)
Returns the intersection of members and their scores from sorted sets specified by the givenkeysOrWeightedKeys.- Parameters:
keysOrWeightedKeys- The keys of the sorted sets with possible formats:- Use
WeightAggregateOptions.KeyArrayBinaryfor keys only. - Use
WeightAggregateOptions.WeightedKeysBinaryfor weighted keys with score multipliers.
- Use
aggregate- Specifies the aggregation strategy to apply when combining the scores of elements.- Returns:
- Command Response - The resulting sorted set from the intersection.
- Since:
- Valkey 6.2 and above.
- See Also:
- valkey.io for more details.
-
xadd
public <ArgType> T xadd(@NonNull ArgType key, @NonNull @NonNull java.util.Map<ArgType,ArgType> values)
Adds an entry to the specified stream stored atkey.
If thekeydoesn't exist, the stream is created. To add entries with duplicate keys, use#xadd(ArgType, ArgType[][]).- Parameters:
key- The key of the stream.values- Field-value pairs to be added to the entry.- Returns:
- Command Response - The id of the added entry.
- See Also:
- valkey.io for details.
-
xadd
public <ArgType> T xadd(@NonNull ArgType key, @NonNull @NonNull ArgType[][] values)
Adds an entry to the specified stream stored atkey.
If thekeydoesn't exist, the stream is created. This method overload allows entries with duplicate keys to be added.- Parameters:
key- The key of the stream.values- Field-value pairs to be added to the entry.- Returns:
- Command Response - The id of the added entry.
- See Also:
- valkey.io for details.
-
xadd
public <ArgType> T xadd(@NonNull ArgType key, @NonNull @NonNull java.util.Map<ArgType,ArgType> values, @NonNull @NonNull StreamAddOptions options)
Adds an entry to the specified stream stored atkey.
If thekeydoesn't exist, the stream is created. To add entries with duplicate keys, use#xadd(ArgType, ArgType[][], StreamAddOptions).- Parameters:
key- The key of the stream.values- Field-value pairs to be added to the entry.options- Stream add optionsStreamAddOptions.- Returns:
- Command Response - The id of the added entry, or
nullifStreamAddOptions.StreamAddOptionsBuilder.makeStream(Boolean)is set tofalseand no stream with the matchingkeyexists. - See Also:
- valkey.io for details.
-
xadd
public <ArgType> T xadd(@NonNull ArgType key, @NonNull @NonNull ArgType[][] values, @NonNull @NonNull StreamAddOptions options)
Adds an entry to the specified stream stored atkey.
If thekeydoesn't exist, the stream is created. This method overload allows entries with duplicate keys to be added.- Parameters:
key- The key of the stream.values- Field-value pairs to be added to the entry.options- Stream add optionsStreamAddOptions.- Returns:
- Command Response - The id of the added entry, or
nullifStreamAddOptions.StreamAddOptionsBuilder.makeStream(Boolean)is set tofalseand no stream with the matchingkeyexists. - See Also:
- valkey.io for details.
-
xread
public <ArgType> T xread(@NonNull @NonNull java.util.Map<ArgType,ArgType> keysAndIds)
Reads entries from the given streams.- Parameters:
keysAndIds- AMapof keys and entry IDs to read from.- Returns:
- Command Response - A
Map<String, Map<String, String[][]>>with stream keys, toMapof stream entry IDs, to an array of pairings with format[[field, entry], [field, entry], ...]. - See Also:
- valkey.io for details.
-
xread
public <ArgType> T xread(@NonNull @NonNull java.util.Map<ArgType,ArgType> keysAndIds, @NonNull @NonNull StreamReadOptions options)
Reads entries from the given streams.- Parameters:
keysAndIds- AMapof keys and entry IDs to read from.options- options detailing how to read the streamStreamReadOptions.- Returns:
- Command Response - A
Map<String, Map<String, String[][]>>with stream keys, toMapof stream entry IDs, to an array of pairings with format[[field, entry], [field, entry], ...]. Returnsnullif all key-ID pairs inkeys_and_idshave either a non-existing key or a non-existing ID, or there are no entries after the given ID, or a timeout is hit in the block option. - See Also:
- valkey.io for details.
-
xtrim
public <ArgType> T xtrim(@NonNull ArgType key, @NonNull @NonNull StreamTrimOptions options)
Trims the stream by evicting older entries.- Parameters:
key- The key of the stream.options- Stream trim optionsStreamTrimOptions.- Returns:
- Command Response - The number of entries deleted from the stream.
- See Also:
- valkey.io for details.
-
xlen
public <ArgType> T xlen(@NonNull ArgType key)
Returns the number of entries in the stream stored atkey.- Parameters:
key- The key of the stream.- Returns:
- Command Response - The number of entries in the stream. If
keydoes not exist, return0. - See Also:
- valkey.io for details.
-
xdel
public <ArgType> T xdel(@NonNull ArgType key, @NonNull @NonNull ArgType[] ids)
Removes the specified entries by id from a stream, and returns the number of entries deleted.- Parameters:
key- The key of the stream.ids- An array of entry ids.- Returns:
- Command Response - The number of entries removed from the stream. This number may be
less than the number of entries in
ids, if the specifiedidsdon't exist in the stream. - See Also:
- valkey.io for details.
-
xrange
public <ArgType> T xrange(@NonNull ArgType key, @NonNull @NonNull StreamRange start, @NonNull @NonNull StreamRange end)
Returns stream entries matching a given range of IDs.- Parameters:
key- The key of the stream.start- Starting stream entry IDs bound for range.- Use
StreamRange.IdBound.of(java.lang.String)to specify a stream entry IDs. - Since Valkey 6.2.0, use
StreamRange.IdBound.ofExclusive(long)to specify an exclusive bounded stream entry ID. - Use
StreamRange.InfRangeBound.MINto start with the minimum available ID.
- Use
end- Ending stream entry IDs bound for range.- Use
StreamRange.IdBound.of(java.lang.String)to specify a stream entry IDs. - Since Valkey 6.2.0, use
StreamRange.IdBound.ofExclusive(long)to specify an exclusive bounded stream entry ID. - Use
StreamRange.InfRangeBound.MAXto end with the maximum available ID.
- Use
- Returns:
- Command Response - A
Mapof key to stream entry data, where entry data is an array of pairings with format[[field, entry], [field, entry], ...]. - See Also:
- valkey.io for details.
-
xrange
public <ArgType> T xrange(@NonNull ArgType key, @NonNull @NonNull StreamRange start, @NonNull @NonNull StreamRange end, long count)
Returns stream entries matching a given range of IDs.- Parameters:
key- The key of the stream.start- Starting stream entry IDs bound for range.- Use
StreamRange.IdBound.of(java.lang.String)to specify a stream entry IDs. - Since Valkey 6.2.0, use
StreamRange.IdBound.ofExclusive(long)to specify an exclusive bounded stream entry ID. - Use
StreamRange.InfRangeBound.MINto start with the minimum available ID.
- Use
end- Ending stream entry IDs bound for range.- Use
StreamRange.IdBound.of(java.lang.String)to specify a stream entry IDs. - Since Valkey 6.2.0, use
StreamRange.IdBound.ofExclusive(long)to specify an exclusive bounded stream entry ID. - Use
StreamRange.InfRangeBound.MAXto end with the maximum available ID.
- Use
count- Maximum count of stream entries to return.- Returns:
- Command Response - A
Mapof key to stream entry data, where entry data is an array of pairings with format[[field, entry], [field, entry], ...]. Returns ornullifcountis non-positive. - See Also:
- valkey.io for details.
-
xrevrange
public <ArgType> T xrevrange(@NonNull ArgType key, @NonNull @NonNull StreamRange end, @NonNull @NonNull StreamRange start)
Returns stream entries matching a given range of IDs in reverse order.
Equivalent to#xrange(ArgType, StreamRange, StreamRange)but returns the entries in reverse order.- Parameters:
key- The key of the stream.end- Ending stream entry IDs bound for range.- Use
StreamRange.IdBound.of(java.lang.String)to specify a stream entry IDs. - Since Valkey 6.2.0, use
StreamRange.IdBound.ofExclusive(long)to specify an exclusive bounded stream entry ID. - Use
StreamRange.InfRangeBound.MAXto end with the maximum available ID.
- Use
start- Starting stream entry IDs bound for range.- Use
StreamRange.IdBound.of(java.lang.String)to specify a stream entry IDs. - Since Valkey 6.2.0, use
StreamRange.IdBound.ofExclusive(long)to specify an exclusive bounded stream entry ID. - Use
StreamRange.InfRangeBound.MINto start with the minimum available ID.
- Use
- Returns:
- Command Response - A
Mapof key to stream entry data, where entry data is an array of pairings with format[[field, entry], [field, entry], ...]. - See Also:
- valkey.io for details.
-
xrevrange
public <ArgType> T xrevrange(@NonNull ArgType key, @NonNull @NonNull StreamRange end, @NonNull @NonNull StreamRange start, long count)
Returns stream entries matching a given range of IDs in reverse order.
Equivalent to#xrange(ArgType, StreamRange, StreamRange, long)but returns the entries in reverse order.- Parameters:
key- The key of the stream.start- Starting stream entry IDs bound for range.- Use
StreamRange.IdBound.of(java.lang.String)to specify a stream entry IDs. - Since Valkey 6.2.0, use
StreamRange.IdBound.ofExclusive(long)to specify an exclusive bounded stream entry ID. - Use
StreamRange.InfRangeBound.MINto start with the minimum available ID.
- Use
end- Ending stream entry IDs bound for range.- Use
StreamRange.IdBound.of(java.lang.String)to specify a stream entry IDs. - Since Valkey 6.2.0, use
StreamRange.IdBound.ofExclusive(long)to specify an exclusive bounded stream entry ID. - Use
StreamRange.InfRangeBound.MAXto end with the maximum available ID.
- Use
count- Maximum count of stream entries to return.- Returns:
- Command Response - A
Mapof key to stream entry data, where entry data is an array of pairings with format[[field, entry], [field, entry], ...]. Returns ornullifcountis non-positive. - See Also:
- valkey.io for details.
-
xgroupCreate
public <ArgType> T xgroupCreate(@NonNull ArgType key, @NonNull ArgType groupName, @NonNull ArgType id)
Creates a new consumer group uniquely identified bygroupnamefor the stream stored atkey.- Parameters:
key- The key of the stream.groupName- The newly created consumer group name.id- 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.- Returns:
- Command Response -
"OK"response on success. - See Also:
- valkey.io for details.
-
xgroupCreate
public <ArgType> T xgroupCreate(@NonNull ArgType key, @NonNull ArgType groupName, @NonNull ArgType id, @NonNull @NonNull StreamGroupOptions options)
Creates a new consumer group uniquely identified bygroupnamefor the stream stored atkey.- Parameters:
key- The key of the stream.groupName- The newly created consumer group name.id- 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.options- The group optionsStreamGroupOptions.- Returns:
- Command Response -
"OK"response on success. - See Also:
- valkey.io for details.
-
xgroupDestroy
public <ArgType> T xgroupDestroy(@NonNull ArgType key, @NonNull ArgType groupName)
Destroys the consumer groupgroupNamefor the stream stored atkey.- Parameters:
key- The key of the stream.groupName- The newly created consumer group name.- Returns:
- Command Response -
trueif the consumer group is destroyed. Otherwise,false. - See Also:
- valkey.io for details.
-
xgroupCreateConsumer
public <ArgType> T xgroupCreateConsumer(@NonNull ArgType key, @NonNull ArgType group, @NonNull ArgType consumer)
Creates a consumer namedconsumerin the consumer groupgroupfor the stream stored atkey.- Parameters:
key- The key of the stream.group- The consumer group name.consumer- The newly created consumer.- Returns:
- Command Response -
trueif the consumer is created. Otherwise,false. - See Also:
- valkey.io for details.
-
xgroupDelConsumer
public <ArgType> T xgroupDelConsumer(@NonNull ArgType key, @NonNull ArgType group, @NonNull ArgType consumer)
Deletes a consumer namedconsumerin the consumer groupgroup.- Parameters:
key- The key of the stream.group- The consumer group name.consumer- The newly created consumer.- Returns:
- Command Response - The number of pending messages the
consumerhad before it was deleted. - See Also:
- valkey.io for details.
-
xgroupSetId
public <ArgType> T xgroupSetId(@NonNull ArgType key, @NonNull ArgType groupName, @NonNull ArgType id)
Sets the last delivered ID for a consumer group.- Parameters:
key- The key of the stream.groupName- The consumer group name.id- The stream entry ID that should be set as the last delivered ID for the consumer group.- Returns:
- Command Response -
"OK"response on success. - See Also:
- valkey.io for details.
-
xgroupSetId
public <ArgType> T xgroupSetId(@NonNull ArgType key, @NonNull ArgType groupName, @NonNull ArgType id, long entriesRead)
Sets the last delivered ID for a consumer group.- Parameters:
key- The key of the stream.groupName- The consumer group name.id- The stream entry ID that should be set as the last delivered ID for the consumer group.entriesRead- A value representing the number of stream entries already read by the group.- Returns:
- Command Response -
"OK"response on success. - Since:
- Valkey 7.0 and above
- See Also:
- valkey.io for details.
-
xreadgroup
public <ArgType> T xreadgroup(@NonNull @NonNull java.util.Map<ArgType,ArgType> keysAndIds, @NonNull ArgType group, @NonNull ArgType consumer)
Reads entries from the given streams owned by a consumer group.- Parameters:
keysAndIds- AMapof keys and entry IDs to read from.
Use the special ID of">"to receive only new messages.group- The consumer group name.consumer- The newly created consumer.- Returns:
- Command Response - A
Map<String, Map<String, String[][]>>with stream keys, toMapof stream entry IDs, to an array of pairings with format[[field, entry], [field, entry], ...]. Returnsnullif there is no stream that can be served. - See Also:
- valkey.io for details.
-
xreadgroup
public <ArgType> T xreadgroup(@NonNull @NonNull java.util.Map<ArgType,ArgType> keysAndIds, @NonNull ArgType group, @NonNull ArgType consumer, @NonNull @NonNull StreamReadGroupOptions options)
Reads entries from the given streams owned by a consumer group.- Parameters:
keysAndIds- AMapof keys and entry IDs to read from.
Use the special ID of">"to receive only new messages.group- The consumer group name.consumer- The newly created consumer.options- Options detailing how to read the streamStreamReadGroupOptions.- Returns:
- Command Response - A
Map<String, Map<String, String[][]>>with stream keys, toMapof stream entry IDs, to an array of pairings with format[[field, entry], [field, entry], ...]. Returnsnullif there is no stream that can be served. - See Also:
- valkey.io for details.
-
xack
public <ArgType> T xack(@NonNull ArgType key, @NonNull ArgType group, @NonNull @NonNull ArgType[] ids)
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- Stream entry ID to acknowledge and purge messages.- Returns:
- Command Response - The number of messages that were successfully acknowledged.
-
xpending
public <ArgType> T xpending(@NonNull ArgType key, @NonNull ArgType group)
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.- Returns:
- Command Response - A 2D-
arraythat includes the summary of pending messages, with the format[NumOfMessages, StartId, EndId, [[Consumer, NumOfMessages], ...], where:NumOfMessages: The total number of pending messages for this consumer group.StartId: The smallest ID among the pending messages.EndId: The greatest ID among the pending messages.[[Consumer, NumOfMessages], ...]: A 2D-arrayof every consumer in the consumer group with at least one pending message, and the number of pending messages it has.
- See Also:
- valkey.io for details.
-
xpending
public <ArgType> T xpending(@NonNull ArgType key, @NonNull ArgType group, @NonNull @NonNull StreamRange start, @NonNull @NonNull StreamRange end, long count)
Returns an extended form of stream message information for pending messages matching a given range of IDs.- Parameters:
key- The key of the stream.group- The consumer group name.start- Starting stream entry IDs bound for range.- Use
StreamRange.IdBound.of(java.lang.String)to specify a stream entry IDs. - Use
StreamRange.IdBound.ofExclusive(long)to specify an exclusive bounded stream entry IDs. - Use
StreamRange.InfRangeBound.MINto start with the minimum available ID.
- Use
end- Ending stream entry IDs bound for range.- Use
StreamRange.IdBound.of(java.lang.String)to specify a stream entry IDs. - Use
StreamRange.IdBound.ofExclusive(long)to specify an exclusive bounded stream entry IDs. - Use
StreamRange.InfRangeBound.MAXto end with the maximum available ID.
- Use
count- Limits the number of messages returned.- Returns:
- Command Response - A 2D-
arrayof 4-tuples containing extended message information with the format[[ID, Consumer, TimeElapsed, NumOfDelivered], ... ], where:ID: The ID of the message.Consumer: The name of the consumer that fetched the message and has still to acknowledge it. We call it the current owner of the message.TimeElapsed: The number of milliseconds that elapsed since the last time this message was delivered to this consumer.NumOfDelivered: The number of times this message was delivered.
- See Also:
- valkey.io for details.
-
xpending
public <ArgType> T xpending(@NonNull ArgType key, @NonNull ArgType group, @NonNull @NonNull StreamRange start, @NonNull @NonNull StreamRange end, long count, @NonNull @NonNull StreamPendingOptions options)
Returns an extended form of stream message information for pending messages matching a given range of IDs.- Parameters:
key- The key of the stream.group- The consumer group name.start- Starting stream entry IDs bound for range.- Use
StreamRange.IdBound.of(java.lang.String)to specify a stream entry IDs. - Use
StreamRange.IdBound.ofExclusive(long)to specify an exclusive bounded stream entry IDs. - Use
StreamRange.InfRangeBound.MINto start with the minimum available ID.
- Use
end- Ending stream entry IDs bound for range.- Use
StreamRange.IdBound.of(java.lang.String)to specify a stream entry IDs. - Use
StreamRange.IdBound.ofExclusive(long)to specify an exclusive bounded stream entry IDs. - Use
StreamRange.InfRangeBound.MAXto end with the maximum available ID.
- Use
count- Limits the number of messages returned.options- Stream add optionsStreamPendingOptions.- Returns:
- Command Response - A 2D-
arrayof 4-tuples containing extended message information with the format[[ID, Consumer, TimeElapsed, NumOfDelivered], ... ], where:ID: The ID of the message.Consumer: The name of the consumer that fetched the message and has still to acknowledge it. We call it the current owner of the message.TimeElapsed: The number of milliseconds that elapsed since the last time this message was delivered to this consumer.NumOfDelivered: The number of times this message was delivered.
- See Also:
- valkey.io for details.
-
xinfoStream
public <ArgType> T xinfoStream(@NonNull ArgType key)
Returns information about the stream stored at keykey.
To get more detailed information use#xinfoStreamFull(ArgType)or#xinfoStreamFull(ArgType, int).- Parameters:
key- The key of the stream.- Returns:
- Command Response - A
Mapof stream information for the givenkey. - See Also:
- valkey.io for details.
-
xinfoStreamFull
public <ArgType> T xinfoStreamFull(@NonNull ArgType key)
Returns verbose information about the stream stored at keykey.
The output is limited by first10PEL entries.- Parameters:
key- The key of the stream.- Returns:
- Command Response - A
Mapof detailed stream information for the givenkey. - Since:
- Valkey 6.0 and above.
- See Also:
- valkey.io for details.
-
xinfoStreamFull
public <ArgType> T xinfoStreamFull(@NonNull ArgType key, int count)
Returns verbose information about the stream stored at keykey.
The output is limited by first10PEL entries.- Parameters:
key- The key of the stream.count- The number of stream and PEL entries that are returned. Value of0means that all entries will be returned.- Returns:
- Command Response - A
Mapof detailed stream information for the givenkey. - Since:
- Valkey 6.0 and above.
- See Also:
- valkey.io for details.
-
xclaim
public <ArgType> T xclaim(@NonNull ArgType key, @NonNull ArgType group, @NonNull ArgType consumer, long minIdleTime, @NonNull @NonNull ArgType[] ids)
Changes the ownership of a pending message.- Parameters:
key- The key of the stream.group- The consumer group name.consumer- The group consumer.minIdleTime- The minimum idle time for the message to be claimed.ids- An array of entry ids.- Returns:
- Command Response - A
Mapof message entries with the format{"entryId": [["entry", "data"], ...], ...}that are claimed by the consumer. - See Also:
- valkey.io for details.
-
xclaim
public <ArgType> T xclaim(@NonNull ArgType key, @NonNull ArgType group, @NonNull ArgType consumer, long minIdleTime, @NonNull @NonNull ArgType[] ids, @NonNull @NonNull StreamClaimOptions options)
Changes the ownership of a pending message.- Parameters:
key- The key of the stream.group- The consumer group name.consumer- The group consumer.minIdleTime- The minimum idle time for the message to be claimed.ids- An array of entry ids.options- Stream claim optionsStreamClaimOptions.- Returns:
- Command Response - A
Mapof message entries with the format{"entryId": [["entry", "data"], ...], ...}that are claimed by the consumer. - See Also:
- valkey.io for details.
-
xclaimJustId
public <ArgType> T xclaimJustId(@NonNull ArgType key, @NonNull ArgType group, @NonNull ArgType consumer, long minIdleTime, @NonNull @NonNull ArgType[] ids)
Changes the ownership of a pending message. This function returns anarraywith only the message/entry IDs, and is equivalent to usingJUSTIDin the Valkey API.- Parameters:
key- The key of the stream.group- The consumer group name.consumer- The group consumer.minIdleTime- The minimum idle time for the message to be claimed.ids- An array of entry ids.- Returns:
- Command Response - An
arrayof message ids claimed by the consumer. - See Also:
- valkey.io for details.
-
xclaimJustId
public <ArgType> T xclaimJustId(@NonNull ArgType key, @NonNull ArgType group, @NonNull ArgType consumer, long minIdleTime, @NonNull @NonNull ArgType[] ids, @NonNull @NonNull StreamClaimOptions options)
Changes the ownership of a pending message. This function returns anarraywith only the message/entry IDs, and is equivalent to usingJUSTIDin the Valkey API.- Parameters:
key- The key of the stream.group- The consumer group name.consumer- The group consumer.minIdleTime- The minimum idle time for the message to be claimed.ids- An array of entry ids.options- Stream claim optionsStreamClaimOptions.- Returns:
- Command Response - An
arrayof message ids claimed by the consumer. - See Also:
- valkey.io for details.
-
xinfoGroups
public <ArgType> T xinfoGroups(@NonNull ArgType key)
Returns the list of all consumer groups and their attributes for the stream stored atkey.- Parameters:
key- The key of the stream.- Returns:
- Command Response - An
ArrayofMaps, where each mapping represents the attributes of a consumer group for the stream atkey. - See Also:
- valkey.io for details.
-
xinfoConsumers
public <ArgType> T xinfoConsumers(@NonNull ArgType key, @NonNull ArgType groupName)
Returns the list of all consumers and their attributes for the given consumer group of the stream stored atkey.- Parameters:
key- The key of the stream.groupName- The consumer group name.- Returns:
- Command Response - An
ArrayofMaps, where each mapping contains the attributes of a consumer for the given consumer group of the stream atkey. - See Also:
- valkey.io for details.
-
xautoclaim
public <ArgType> T xautoclaim(@NonNull ArgType key, @NonNull ArgType group, @NonNull ArgType consumer, long minIdleTime, @NonNull ArgType start)
Transfers ownership of pending stream entries that match the specified criteria.- Parameters:
key- The key of the stream.group- The consumer group nameconsumer- The group consumer.minIdleTime- The minimum idle time for the message to be claimed.start- Filters the claimed entries to those that have an ID equal or greater than the specified value.- Returns:
- Command Response - An
arraycontaining the following elements:- A stream entry IDs 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, with the keys being the claimed entry IDs and the
values being a 2D list of the field-value pairs in the format
[[field1, value1], [field2, value2], ...]. - 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.
- A stream entry IDs to be used as the start argument for the next call to
- See Also:
- valkey.io for details.
-
xautoclaim
public <ArgType> T xautoclaim(@NonNull ArgType key, @NonNull ArgType group, @NonNull ArgType consumer, long minIdleTime, @NonNull ArgType start, long count)
Transfers ownership of pending stream entries that match the specified criteria.- Parameters:
key- The key of the stream.group- The consumer group nameconsumer- The group consumer.minIdleTime- The minimum idle time for the message to be claimed.start- Filters the claimed entries to those that have an ID equal or greater than the specified value.count- Limits the number of claimed entries to the specified value. Default value is 100.- Returns:
- Command Response - An
arraycontaining the following elements:- A stream entry IDs 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, with the keys being the claimed entry IDs and the
values being a 2D list of the field-value pairs in the format
[[field1, value1], [field2, value2], ...]. - 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.
- A stream entry IDs to be used as the start argument for the next call to
- See Also:
- valkey.io for details.
-
xautoclaimJustId
public <ArgType> T xautoclaimJustId(@NonNull ArgType key, @NonNull ArgType group, @NonNull ArgType consumer, long minIdleTime, @NonNull ArgType start)
Transfers ownership of pending stream entries that match the specified criteria. This command uses theJUSTIDargument to further specify that the return value should contain a list of claimed IDs without their field-value info.- Parameters:
key- The key of the stream.group- The consumer group nameconsumer- The group consumer.minIdleTime- The minimum idle time for the message to be claimed.start- Filters the claimed entries to those that have an ID equal or greater than the specified value.- Returns:
- Command Response - An
arraycontaining the following elements:- A stream entry IDs 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.
- A stream entry IDs to be used as the start argument for the next call to
- See Also:
- valkey.io for details.
-
xautoclaimJustId
public <ArgType> T xautoclaimJustId(@NonNull ArgType key, @NonNull ArgType group, @NonNull ArgType consumer, long minIdleTime, @NonNull ArgType start, long count)
Transfers ownership of pending stream entries that match the specified criteria. This command uses theJUSTIDargument to further specify that the return value should contain a list of claimed IDs without their field-value info.- Parameters:
key- The key of the stream.group- The consumer group nameconsumer- The group consumer.minIdleTime- The minimum idle time for the message to be claimed.start- Filters the claimed entries to those that have an ID equal or greater than the specified value.count- Limits the number of claimed entries to the specified value. Default value is 100.- Returns:
- Command Response - An
arraycontaining the following elements:- A stream entry IDs 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.
- A stream entry IDs to be used as the start argument for the next call to
- See Also:
- valkey.io for details.
-
pttl
public <ArgType> T pttl(@NonNull ArgType key)
Returns the remaining time to live ofkeythat has a timeout, in milliseconds.- Parameters:
key- The key to return its timeout.- Returns:
- Command Response - TTL in milliseconds.
-2ifkeydoes not exist,-1ifkeyexists but has no associated expire. - See Also:
- valkey.io for details.
-
persist
public <ArgType> T persist(@NonNull ArgType key)
Removes the existing timeout onkey, turning thekeyfrom volatile (akeywith an expire set) to persistent (akeythat will never expire as no timeout is associated).- Parameters:
key- Thekeyto remove the existing timeout on.- Returns:
- Command Response -
falseifkeydoes not exist or does not have an associated timeout,trueif the timeout has been removed. - See Also:
- valkey.io for details.
-
time
public T time()
Returns the server time.- Returns:
- Command Response - The current server time as a
Stringarray with two elements: AUNIX TIMEand the amount of microseconds already elapsed in the current second. The returned array is in a[UNIX TIME, Microseconds already elapsed]format. - See Also:
- valkey.io for details.
-
lastsave
public T lastsave()
ReturnsUNIX TIMEof the last DB save timestamp or startup timestamp if no save was made since then.- Returns:
- Command Response -
UNIX TIMEof the last DB save executed with success. - See Also:
- valkey.io for details.
-
flushall
public T flushall()
Deletes all the keys of all the existing databases. This command never fails.- Returns:
- Command Response -
"OK"response on success. - See Also:
- valkey.io for details.
-
flushall
public T flushall(FlushMode mode)
Deletes all the keys of all the existing databases. This command never fails.- Parameters:
mode- The flushing mode, could be eitherFlushMode.SYNCorFlushMode.ASYNC.- Returns:
- Command Response -
"OK"response on success. - See Also:
- valkey.io for details.
-
flushdb
public T flushdb()
Deletes all the keys of the currently selected database. This command never fails.- Returns:
- Command Response -
"OK"response on success. - See Also:
- valkey.io for details.
-
flushdb
public T flushdb(FlushMode mode)
Deletes all the keys of the currently selected database. This command never fails.- Parameters:
mode- The flushing mode, could be eitherFlushMode.SYNCorFlushMode.ASYNC.- Returns:
- Command Response -
"OK"response on success. - See Also:
- valkey.io for details.
-
lolwut
public T lolwut()
Displays a piece of generative computer art and the server version.- Returns:
- Command Response - A piece of generative computer art along with the current Valkey version.
- See Also:
- valkey.io for details.
-
lolwut
public T lolwut(int @NonNull [] parameters)
Displays a piece of generative computer art and the server version.- Parameters:
parameters- Additional set of arguments in order to change the output:- On the server version
5, those are length of the line, number of squares per row, and number of squares per column. - On the server version
6, those are number of columns and number of lines. - On other versions parameters are ignored.
- On the server version
- Returns:
- Command Response - A piece of generative computer art along with the current Valkey version.
- See Also:
- valkey.io for details.
-
lolwut
public T lolwut(int version)
Displays a piece of generative computer art and the server version.- Parameters:
version- Version of computer art to generate.- Returns:
- Command Response - A piece of generative computer art along with the current Valkey version.
- See Also:
- valkey.io for details.
-
lolwut
public T lolwut(int version, int @NonNull [] parameters)
Displays a piece of generative computer art and the server version.- Parameters:
version- Version of computer art to generate.parameters- Additional set of arguments in order to change the output:- For version
5, those are length of the line, number of squares per row, and number of squares per column. - For version
6, those are number of columns and number of lines.
- For version
- Returns:
- Command Response - A piece of generative computer art along with the current Valkey version.
- See Also:
- valkey.io for details.
-
dbsize
public T dbsize()
Returns the number of keys in the currently selected database.- Returns:
- Command Response - The number of keys in the currently selected database.
- See Also:
- valkey.io for details.
-
type
public <ArgType> T type(@NonNull ArgType key)
Returns the string representation of the type of the value stored atkey.- Parameters:
key- Thekeyto check its data type.- Returns:
- Command Response - If the
keyexists, the type of the stored value is returned. Otherwise, a "none" string is returned. - See Also:
- valkey.io for details.
-
randomKey
public T randomKey()
Returns a random key from the currently selected database. *- Returns:
- Command Response - A random
keyfrom the database. - See Also:
- valkey.io for details.
-
rename
public <ArgType> T rename(@NonNull ArgType key, @NonNull ArgType newKey)
RenameskeytonewKey.
IfnewKeyalready exists it is overwritten.- Parameters:
key- Thekeyto rename.newKey- The new name of thekey.- Returns:
- Command Response - If the
keywas successfully renamed, returnsOK. Ifkeydoes not exist, the command fails with an error. - See Also:
- valkey.io for details.
-
renamenx
public <ArgType> T renamenx(@NonNull ArgType key, @NonNull ArgType newKey)
RenameskeytonewKeyifnewKeydoes not yet exist.- Parameters:
key- The key to rename.newKey- The new key name.- Returns:
- Command Response -
trueifkeywas renamed tonewKey,falseifnewKeyalready exists. - See Also:
- valkey.io for details.
-
linsert
public <ArgType> T linsert(@NonNull ArgType key, @NonNull @NonNull LInsertOptions.InsertPosition position, @NonNull ArgType pivot, @NonNull ArgType element)
Insertselementin the list atkeyeither before or after thepivot.- Parameters:
key- The key of the list.position- The relative position to insert into - eitherLInsertOptions.InsertPosition.BEFOREorLInsertOptions.InsertPosition.AFTERthepivot.pivot- An element of the list.element- The new element to insert.- Returns:
- Command Response - The list length after a successful insert operation.
If thekeydoesn't exist returns-1.
If thepivotwasn't found, returns0. - See Also:
- valkey.io for details.
-
brpop
public <ArgType> T brpop(@NonNull @NonNull ArgType[] keys, double timeout)
Pops an element from the tail of the first list that is non-empty, with the givenkeysbeing 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- Thekeysof the lists to pop from.timeout- The number of seconds to wait for a blocking operation to complete. A value of0will block indefinitely.- Returns:
- Command Response - A two-element
arraycontaining thekeyfrom which the element was popped and thevalueof the popped element, formatted as[key, value]. If no element could be popped and the timeout expired, returnsnull. - See Also:
- valkey.io for details.
-
lpushx
public <ArgType> T lpushx(@NonNull ArgType key, @NonNull @NonNull ArgType[] elements)
Inserts all the specified values at the head of the list stored atkey, only ifkeyexists and holds a list. Ifkeyis not a list, this performs no operation.- Parameters:
key- The key of the list.elements- The elements to insert at the head of the list stored atkey.- Returns:
- Command Response - The length of the list after the push operation.
- See Also:
- valkey.io for details.
-
rpushx
public <ArgType> T rpushx(@NonNull ArgType key, @NonNull @NonNull ArgType[] elements)
Inserts all the specified values at the tail of the list stored atkey, only ifkeyexists and holds a list. Ifkeyis not a list, this performs no operation.- Parameters:
key- The key of the list.elements- The elements to insert at the tail of the list stored atkey.- Returns:
- Command Response - The length of the list after the push operation.
- See Also:
- valkey.io for details.
-
blpop
public <ArgType> T blpop(@NonNull @NonNull ArgType[] keys, double timeout)
Pops an element from the head of the first list that is non-empty, with the givenkeysbeing 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- Thekeysof the lists to pop from.timeout- The number of seconds to wait for a blocking operation to complete. A value of0will block indefinitely.- Returns:
- Command Response - A two-element
arraycontaining thekeyfrom which the element was popped and thevalueof the popped element, formatted as[key, value]. If no element could be popped and the timeout expired, returnsnull. - See Also:
- valkey.io for details.
-
zrange
public <ArgType> T zrange(@NonNull ArgType key, @NonNull @NonNull RangeOptions.RangeQuery rangeQuery, boolean reverse)
Returns the specified range of elements in the sorted set stored atkey.
ZRANGEcan perform different types of range queries: by index (rank), by the score, or by lexicographical order.
To get the elements with their scores, seezrangeWithScores(ArgType, glide.api.models.commands.RangeOptions.ScoredRangeQuery, boolean).- 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
RangeOptions.RangeByIndex. - For range queries by lexicographical order, use
RangeOptions.RangeByLex. - For range queries by score, use
RangeOptions.RangeByScore.
- For range queries by index (rank), use
reverse- If true, reverses the sorted set, with index 0 as the element with the highest score.- Returns:
- Command Response - An
arrayof elements within the specified range. Ifkeydoes not exist, it is treated as an empty sorted set, and the command returns an emptyarray. - See Also:
- valkey.io for more details.
-
zrange
public <ArgType> T zrange(@NonNull ArgType key, @NonNull @NonNull RangeOptions.RangeQuery rangeQuery)
Returns the specified range of elements in the sorted set stored atkey.
ZRANGEcan perform different types of range queries: by index (rank), by the score, or by lexicographical order.
To get the elements with their scores, seezrangeWithScores(ArgType, glide.api.models.commands.RangeOptions.ScoredRangeQuery, boolean).- 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
RangeOptions.RangeByIndex. - For range queries by lexicographical order, use
RangeOptions.RangeByLex. - For range queries by score, use
RangeOptions.RangeByScore.
- For range queries by index (rank), use
- Returns:
- Command Response - An
arrayof elements within the specified range. Ifkeydoes not exist, it is treated as an empty sorted set, and the command returns an emptyarray. - See Also:
- valkey.io for more details.
-
zrangeWithScores
public <ArgType> T zrangeWithScores(@NonNull ArgType key, @NonNull @NonNull RangeOptions.ScoredRangeQuery rangeQuery, boolean reverse)
Returns the specified range of elements with their scores in the sorted set stored atkey. Similar tozrange(ArgType, glide.api.models.commands.RangeOptions.RangeQuery, boolean)but with aWITHSCOREflag.- 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
RangeOptions.RangeByIndex. - For range queries by score, use
RangeOptions.RangeByScore.
- For range queries by index (rank), use
reverse- If true, reverses the sorted set, with index 0 as the element with the highest score.- Returns:
- Command Response - A
Mapof elements and their scores within the specified range. Ifkeydoes not exist, it is treated as an empty sorted set, and the command returns an emptyMap. - See Also:
- valkey.io for more details.
-
zrangeWithScores
public <ArgType> T zrangeWithScores(@NonNull ArgType key, @NonNull @NonNull RangeOptions.ScoredRangeQuery rangeQuery)
Returns the specified range of elements with their scores in the sorted set stored atkey. Similar tozrange(ArgType, glide.api.models.commands.RangeOptions.RangeQuery, boolean)but with aWITHSCOREflag.- 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
RangeOptions.RangeByIndex. - For range queries by score, use
RangeOptions.RangeByScore.
- For range queries by index (rank), use
- Returns:
- Command Response - A
Mapof elements and their scores within the specified range. Ifkeydoes not exist, it is treated as an empty sorted set, and the command returns an emptyMap. - See Also:
- valkey.io for more details.
-
zmpop
public <ArgType> T zmpop(@NonNull @NonNull ArgType[] keys, @NonNull @NonNull ScoreFilter modifier)
Pops a member-score pair from the first non-empty sorted set, with the givenkeysbeing checked in the order they are provided.- Parameters:
keys- The keys of the sorted sets.modifier- The element pop criteria - eitherScoreFilter.MINorScoreFilter.MAXto pop the member with the lowest/highest score accordingly.- Returns:
- Command Response - A two-element
arraycontaining the key name of the set from which the element was popped, and a member-scoreMapof the popped element.
If no member could be popped, returnsnull. - Since:
- Valkey 7.0 and above.
- See Also:
- valkey.io for more details.
-
zmpop
public <ArgType> T zmpop(@NonNull @NonNull ArgType[] keys, @NonNull @NonNull ScoreFilter modifier, long count)
Pops multiple member-score pairs from the first non-empty sorted set, with the givenkeysbeing checked in the order they are provided.- Parameters:
keys- The keys of the sorted sets.modifier- The element pop criteria - eitherScoreFilter.MINorScoreFilter.MAXto pop members with the lowest/highest scores accordingly.count- The number of elements to pop.- Returns:
- Command Response - A two-element
arraycontaining the key name of the set from which elements were popped, and a member-scoreMapof the popped elements.
If no member could be popped, returnsnull. - Since:
- Valkey 7.0 and above.
- See Also:
- valkey.io for more details.
-
bzmpop
public <ArgType> T bzmpop(@NonNull @NonNull ArgType[] keys, @NonNull @NonNull ScoreFilter modifier, double timeout)
Blocks the connection until it pops and returns a member-score pair from the first non-empty sorted set, with the givenkeysbeing checked in the order they are provided.
BZMPOPis the blocking variant of#zmpop(ArgType[], ScoreFilter).- Parameters:
keys- The keys of the sorted sets.modifier- The element pop criteria - eitherScoreFilter.MINorScoreFilter.MAXto pop members with the lowest/highest scores accordingly.timeout- The number of seconds to wait for a blocking operation to complete. A value of0will block indefinitely.- Returns:
- Command Response - A two-element
arraycontaining the key name of the set from which an element was popped, and a member-scoreMapof the popped elements.
If no member could be popped and the timeout expired, returnsnull. - Since:
- Valkey 7.0 and above.
- See Also:
- valkey.io for more details.
-
bzmpop
public <ArgType> T bzmpop(@NonNull @NonNull ArgType[] keys, @NonNull @NonNull ScoreFilter modifier, double timeout, long count)
Blocks the connection until it pops and returns multiple member-score pairs from the first non-empty sorted set, with the givenkeysbeing checked in the order they are provided.
BZMPOPis the blocking variant of#zmpop(ArgType[], ScoreFilter, long).- Parameters:
keys- The keys of the sorted sets.modifier- The element pop criteria - eitherScoreFilter.MINorScoreFilter.MAXto pop members with the lowest/highest scores accordingly.timeout- The number of seconds to wait for a blocking operation to complete. A value of0will block indefinitely.count- The number of elements to pop.- Returns:
- Command Response - A two-element
arraycontaining the key name of the set from which elements were popped, and a member-scoreMapof the popped elements.
If no members could be popped and the timeout expired, returnsnull. - Since:
- Valkey 7.0 and above.
- See Also:
- valkey.io for more details.
-
pfadd
public <ArgType> T pfadd(@NonNull ArgType key, @NonNull @NonNull ArgType[] elements)
Adds all elements to the HyperLogLog data structure stored at the specifiedkey.
Creates a new structure if thekeydoes not exist.When no
elementsare provided, andkeyexists and is a HyperLogLog, then no operation is performed. Ifkeydoes not exist, then the HyperLogLog structure is created.- Parameters:
key- Thekeyof the HyperLogLog data structure to add elements into.elements- Anarrayof members to add to the HyperLogLog stored atkey.- Returns:
- Command Response - If the HyperLogLog is newly created, or if the HyperLogLog
approximated cardinality is altered, then returns
true. Otherwise, returnsfalse. - See Also:
- valkey.io for details.
-
pfcount
public <ArgType> T pfcount(@NonNull @NonNull ArgType[] keys)
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.- Returns:
- Command Response - The approximated cardinality of given HyperLogLog data structures.
The cardinality of a key that does not exist is0. - See Also:
- valkey.io for details.
-
pfmerge
public <ArgType> T pfmerge(@NonNull ArgType destination, @NonNull @NonNull ArgType[] sourceKeys)
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.- Returns:
- Command Response -
"OK"response on success. - See Also:
- valkey.io for details.
-
objectEncoding
public <ArgType> T objectEncoding(@NonNull ArgType key)
Returns the internal encoding for the server object stored atkey.- Parameters:
key- Thekeyof the object to get the internal encoding of.- Returns:
- Command response - If
keyexists, returns the internal encoding of the object stored atkeyas aString. Otherwise, returnnull. - See Also:
- valkey.io for details.
-
objectFreq
public <ArgType> T objectFreq(@NonNull ArgType key)
Returns the logarithmic access frequency counter of a server object stored atkey.- Parameters:
key- Thekeyof the object to get the logarithmic access frequency counter of.- Returns:
- Command response - If
keyexists, returns the logarithmic access frequency counter of the object stored atkeyas aLong. Otherwise, returnsnull. - See Also:
- valkey.io for details.
-
objectIdletime
public <ArgType> T objectIdletime(@NonNull ArgType key)
Returns the time in seconds since the last access to the value stored atkey.- Parameters:
key- Thekeyof the object to get the idle time of.- Returns:
- Command response - If
keyexists, returns the idle time in seconds. Otherwise, returnsnull. - See Also:
- valkey.io for details.
-
objectRefcount
public <ArgType> T objectRefcount(@NonNull ArgType key)
Returns the reference count of the object stored atkey.- Parameters:
key- Thekeyof the object to get the reference count of.- Returns:
- Command response - If
keyexists, returns the reference count of the object stored atkeyas aLong. Otherwise, returnsnull. - See Also:
- valkey.io for details.
-
touch
public <ArgType> T touch(@NonNull @NonNull ArgType[] keys)
Updates the last access time of specifiedkeys.- Parameters:
keys- The keys to update last access time.- Returns:
- Command Response - The number of keys that were updated.
- See Also:
- valkey.io for details.
-
copy
public <ArgType> T copy(@NonNull ArgType source, @NonNull ArgType destination, boolean replace)
Copies the value stored at thesourceto thedestinationkey. Whenreplaceis true, removes thedestinationkey 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.replace- If the destination key should be removed before copying the value to it.- Returns:
- Command Response -
trueifsourcewas copied,falseifsourcewas not copied. - Since:
- Valkey 6.2.0 and above.
- See Also:
- valkey.io for details.
-
copy
public <ArgType> T copy(@NonNull ArgType source, @NonNull ArgType destination)
Copies the value stored at thesourceto thedestinationkey if thedestinationkey does not yet exist.- Parameters:
source- The key to the source value.destination- The key where the value should be copied to.- Returns:
- Command Response -
trueifsourcewas copied,falseifsourcewas not copied. - Since:
- Valkey 6.2.0 and above.
- See Also:
- valkey.io for details.
-
copy
public <ArgType> T copy(@NonNull ArgType source, @NonNull ArgType destination, long destinationDB)
Copies the value stored at thesourceto thedestinationkey ondestinationDB. Whenreplaceis true, removes thedestinationkey 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.destinationDB- The alternative logical database index for the destination key.- Returns:
- Command Response -
trueifsourcewas copied,falseifsourcewas not copied. - Since:
- Valkey 6.2.0 and above for standalone Client., Valkey 9.0.0 and above for standaloneClient.
- See Also:
- valkey.io for details.
-
copy
public <ArgType> T copy(@NonNull ArgType source, @NonNull ArgType destination, long destinationDB, boolean replace)
Copies the value stored at thesourceto thedestinationkey ondestinationDB. Whenreplaceis true, removes thedestinationkey 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.destinationDB- The alternative logical database index for the destination key.replace- If the destination key should be removed before copying the value to it.- Returns:
- Command Response -
trueifsourcewas copied,falseifsourcewas not copied. - Since:
- Valkey 6.2.0 and above for standalone Client., Valkey 9.0.0 and above for standaloneClient.
- See Also:
- valkey.io for details.
-
dump
public <ArgType> T dump(@NonNull ArgType key)
Serialize the value stored atkeyin a Valkey-specific format and return it to the user.- Parameters:
key- Thekeyto serialize.- Returns:
- Command Response - The serialized value of the data stored at
key.
Ifkeydoes not exist,nullwill be returned. - See Also:
- valkey.io for details.
-
restore
public <ArgType> T restore(@NonNull ArgType key, long ttl, @NonNull @lombok.NonNull byte[] value)
Create akeyassociated with avaluethat is obtained by deserializing the provided serializedvalue(obtained viadump(ArgType)).- Parameters:
key- Thekeyto create.ttl- The expiry time (in milliseconds). If0, thekeywill persist.value- The serialized value to deserialize and assign tokey.- Returns:
- Command Response -
"OK"response on success. - See Also:
- valkey.io for details.
-
restore
public <ArgType> T restore(@NonNull ArgType key, long ttl, @NonNull @lombok.NonNull byte[] value, @NonNull @NonNull RestoreOptions restoreOptions)
Create akeyassociated with avaluethat is obtained by deserializing the provided serializedvalue(obtained viadump(ArgType)).- Parameters:
key- Thekeyto create.ttl- The expiry time (in milliseconds). If0, thekeywill persist.value- The serialized value to deserialize and assign tokey.restoreOptions- The restore options. SeeRestoreOptions.- Returns:
- Command Response -
"OK"response on success. - See Also:
- valkey.io for details.
-
bitcount
public <ArgType> T bitcount(@NonNull ArgType key)
Counts the number of set bits (population counting) in a string stored atkey.- Parameters:
key- The key for the string to count the set bits of.- Returns:
- Command Response - The number of set bits in the string. Returns zero if the key is missing as it is treated as an empty string.
- See Also:
- valkey.io for details.
-
bitcount
public <ArgType> T bitcount(@NonNull ArgType key, long start)
Counts the number of set bits (population counting) in a string stored atkey. The offsetstartis a zero-based index, with0being the first byte of the list,1being the next byte and so on. This offset can also be a negative number indicating offsets starting at the end of the list, with-1being the last byte of the list,-2being the penultimate, and so on.- Parameters:
key- The key for the string to count the set bits of.start- The starting offset byte index.- Returns:
- Command Response - The number of set bits in the string byte interval specified by
startto the last byte. Returns zero if the key is missing as it is treated as an empty string. - See Also:
- valkey.io for details.
-
bitcount
public <ArgType> T bitcount(@NonNull ArgType key, long start, long end)
Counts the number of set bits (population counting) in a string stored atkey. The offsetsstartandendare zero-based indexes, with0being the first element of the list,1being the next element and so on. These offsets can also be negative numbers indicating offsets starting at the end of the list, with-1being the last element of the list,-2being the penultimate, and so on.- Parameters:
key- The key for the string to count the set bits of.start- The starting byte offset.end- The ending byte offset.- Returns:
- Command Response - The number of set bits in the string byte interval specified by
startandend. Returns zero if the key is missing as it is treated as an empty string. - See Also:
- valkey.io for details.
-
bitcount
public <ArgType> T bitcount(@NonNull ArgType key, long start, long end, @NonNull @NonNull BitmapIndexType options)
Counts the number of set bits (population counting) in a string stored atkey. The offsetsstartandendare zero-based indexes, with0being the first element of the list,1being the next element and so on. These offsets can also be negative numbers indicating offsets starting at the end of the list, with-1being the last element of the list,-2being the penultimate, and so on.- Parameters:
key- The key for the string to count the set bits of.start- The starting offset.end- The ending offset.options- The index offset type. Could be eitherBitmapIndexType.BITorBitmapIndexType.BYTE.- Returns:
- Command Response - The number of set bits in the string interval specified by
start,end, andoptions. Returns zero if the key is missing as it is treated as an empty string. - Since:
- Valkey 7.0 and above
- See Also:
- valkey.io for details.
-
geoadd
public <ArgType> T geoadd(@NonNull ArgType key, @NonNull @NonNull java.util.Map<ArgType,GeospatialData> membersToGeospatialData, @NonNull @NonNull GeoAddOptions options)
Adds geospatial members with their positions to the specified sorted set stored atkey.
If a member is already a part of the sorted set, its position is updated.- Parameters:
key- The key of the sorted set.membersToGeospatialData- A mapping of member names to their corresponding positions - seeGeospatialData. The command will report an error when the user attempts to index coordinates outside the specified ranges.options- The GeoAdd options - seeGeoAddOptions- Returns:
- Command Response - The number of elements added to the sorted set. If
changedis set totruein the options, returns the number of elements updated in the sorted set. - See Also:
- valkey.io for more details.
-
geoadd
public <ArgType> T geoadd(@NonNull ArgType key, @NonNull @NonNull java.util.Map<ArgType,GeospatialData> membersToGeospatialData)
Adds geospatial members with their positions to the specified sorted set stored atkey.
If a member is already a part of the sorted set, its position is updated.
To perform ageoaddoperation while specifying optional parameters, use#geoadd(ArgType, Map, GeoAddOptions).- Parameters:
key- The key of the sorted set.membersToGeospatialData- A mapping of member names to their corresponding positions - seeGeospatialData. The command will report an error when the user attempts to index coordinates outside the specified ranges.- Returns:
- Command Response - The number of elements added to the sorted set.
- See Also:
- valkey.io for more details.
-
geopos
public <ArgType> T geopos(@NonNull ArgType key, @NonNull @NonNull ArgType[] members)
Returns the positions (longitude,latitude) of all the specifiedmembersof the geospatial index represented by the sorted set atkey.- Parameters:
key- The key of the sorted set.members- The members for which to get the positions.- Returns:
- Command Response - A 2D
arraywhich represent positions (longitude and latitude) corresponding to the given members. If a member does not exist, its position will benull. - See Also:
- valkey.io for more details.
-
geodist
public <ArgType> T geodist(@NonNull ArgType key, @NonNull ArgType member1, @NonNull ArgType member2, @NonNull @NonNull GeoUnit geoUnit)
Returns the distance betweenmember1andmember2saved in the geospatial index stored atkey.- Parameters:
key- The key of the sorted set.member1- The name of the first member.member2- The name of the second member.geoUnit- The unit of distance measurement - seeGeoUnit.- Returns:
- Command Response - The distance between
member1andmember2. If one or both members do not exist or if the key does not exist returnsnull. - See Also:
- valkey.io for more details.
-
geodist
public <ArgType> T geodist(@NonNull ArgType key, @NonNull ArgType member1, @NonNull ArgType member2)
Returns the distance betweenmember1andmember2saved in the geospatial index stored atkey.- Parameters:
key- The key of the sorted set.member1- The name of the first member.member2- The name of the second member.- Returns:
- Command Response - The distance between
member1andmember2. If one or both members do not exist or if the key does not exist returnsnull. The default unit isGeoUnit.METERS. - See Also:
- valkey.io for more details.
-
geohash
public <ArgType> T geohash(@NonNull ArgType key, @NonNull @NonNull ArgType[] members)
Returns theGeoHashstrings representing the positions of all the specifiedmembersin the sorted set stored atkey.- Parameters:
key- The key of the sorted set.members- The array of members whoseGeoHashstrings are to be retrieved.- Returns:
- Command Response - An array of
GeoHashstrings representing the positions of the specified members stored atkey. If a member does not exist in the sorted set, anullvalue is returned for that member. - See Also:
- valkey.io for more details.
-
functionLoad
public <ArgType> T functionLoad(@NonNull ArgType libraryCode, boolean replace)
Loads a library to Valkey.- Parameters:
libraryCode- The source code that implements the library.replace- Whether the given library should overwrite a library with the same name if it already exists.- Returns:
- Command Response - The library name that was loaded.
- Since:
- Valkey 7.0 and above.
- See Also:
- valkey.io for details.
-
functionList
public T functionList(boolean withCode)
Returns information about the functions and libraries.- Parameters:
withCode- Specifies whether to request the library code from the server or not.- Returns:
- Command Response - Info about all libraries and their functions.
- Since:
- Valkey 7.0 and above.
- See Also:
- valkey.io for details.
-
functionList
public <ArgType> T functionList(@NonNull ArgType libNamePattern, boolean withCode)
Returns information about the functions and libraries.- Parameters:
libNamePattern- A wildcard pattern for matching library names.withCode- Specifies whether to request the library code from the server or not.- Returns:
- Command Response - Info about queried libraries and their functions.
- Since:
- Valkey 7.0 and above.
- See Also:
- valkey.io for details.
-
fcall
public <ArgType> T fcall(@NonNull ArgType function, @NonNull @NonNull ArgType[] keys, @NonNull @NonNull ArgType[] arguments)
Invokes a previously loaded function.- Parameters:
function- The function name.keys- Anarrayof key arguments accessed by the function. To ensure the correct execution of functions, both in standalone and clustered deployments, all names of keys that a function accesses must be explicitly provided askeys.arguments- Anarrayoffunctionarguments.argumentsshould not represent names of keys.- Returns:
- Command Response - The invoked function's return value.
- Since:
- Valkey 7.0 and above.
- See Also:
- valkey.io for details.
-
fcall
public <ArgType> T fcall(@NonNull ArgType function, @NonNull @NonNull ArgType[] arguments)
Invokes a previously loaded read-only function.- Parameters:
function- The function name.arguments- Anarrayoffunctionarguments.argumentsshould not represent names of keys.- Returns:
- Command Response - The invoked function's return value.
- Since:
- Valkey 7.0 and above.
- See Also:
- valkey.io for details.
-
fcallReadOnly
public <ArgType> T fcallReadOnly(@NonNull ArgType function, @NonNull @NonNull ArgType[] keys, @NonNull @NonNull ArgType[] arguments)
Invokes a previously loaded read-only function.- Parameters:
function- The function name.keys- Anarrayof key arguments accessed by the function. To ensure the correct execution of functions, both in standalone and clustered deployments, all names of keys that a function accesses must be explicitly provided askeys.arguments- Anarrayoffunctionarguments.argumentsshould not represent names of keys.- Returns:
- Command Response - The invoked function's return value.
- Since:
- Valkey 7.0 and above.
- See Also:
- valkey.io for details.
-
fcallReadOnly
public <ArgType> T fcallReadOnly(@NonNull ArgType function, @NonNull @NonNull ArgType[] arguments)
Invokes a previously loaded function.- Parameters:
function- The function name.arguments- Anarrayoffunctionarguments.argumentsshould not represent names of keys.- Returns:
- Command Response - The invoked function's return value.
- Since:
- Valkey 7.0 and above.
- See Also:
- valkey.io for details.
-
functionStats
public T functionStats()
Returns information about the function that's currently running and information about the available execution engines.- Returns:
- Command Response - A
Mapwith two keys:running_scriptwith information about the running script.engineswith information about available engines and their stats.
- Since:
- Valkey 7.0 and above.
- See Also:
- valkey.io for details.
-
functionDump
public T functionDump()
Returns the serialized payload of all loaded libraries. The command will be routed to a random node.- Returns:
- Command Response - The serialized payload of all loaded libraries.
- Since:
- Valkey 7.0 and above.
- See Also:
- valkey.io for details.
-
functionRestore
public T functionRestore(@NonNull @lombok.NonNull byte[] payload)
Restores libraries from the serialized payload returned byfunctionDump(). The command will be routed to all primary nodes.- Parameters:
payload- The serialized data fromfunctionDump().- Returns:
- Command Response -
"OK"response on success. - Since:
- Valkey 7.0 and above.
- See Also:
- valkey.io for details.
-
functionRestore
public T functionRestore(@NonNull @lombok.NonNull byte[] payload, @NonNull @NonNull FunctionRestorePolicy policy)
Restores libraries from the serialized payload returned byfunctionDump(). The command will be routed to all primary nodes.- Parameters:
payload- The serialized data fromfunctionDump().policy- A policy for handling existing libraries.- Returns:
- Command Response -
"OK"response on success. - Since:
- Valkey 7.0 and above.
- See Also:
- valkey.io for details.
-
setbit
public <ArgType> T setbit(@NonNull ArgType key, long offset, long value)
Sets or clears the bit atoffsetin the string value stored atkey. Theoffsetis a zero-based index, with0being the first element of the list,1being the next element, and so on. Theoffsetmust be less than2^32and greater than or equal to0. If a key is non-existent then the bit atoffsetis set tovalueand the preceding bits are set to0.- Parameters:
key- The key of the string.offset- The index of the bit to be set.value- The bit value to set atoffset. The value must be0or1.- Returns:
- Command Response - The bit value that was previously stored at
offset. - See Also:
- valkey.io for details.
-
getbit
public <ArgType> T getbit(@NonNull ArgType key, long offset)
Returns the bit value atoffsetin the string value stored atkey.offsetshould be greater than or equal to zero.- Parameters:
key- The key of the string.offset- The index of the bit to return.- Returns:
- Command Response - The bit at offset of the string. Returns zero if the key is empty or
if the positive
offsetexceeds the length of the string. - See Also:
- valkey.io for details.
-
blmpop
public <ArgType> T blmpop(@NonNull @NonNull ArgType[] keys, @NonNull @NonNull ListDirection direction, @NonNull @NonNull java.lang.Long count, double timeout)
Blocks the connection until it pops one or more elements from the first non-empty list from the providedkeys.BLMPOPis the blocking variant of#lmpop(ArgType[], ListDirection, Long).- Parameters:
keys- The list of providedkeynames.direction- The direction based on which elements are popped from - seeListDirection.count- The maximum number of popped elements.timeout- The number of seconds to wait for a blocking operation to complete. A value of0will block indefinitely.- Returns:
- Command Response - A
Mapofkeynames arrays of popped elements.
If no member could be popped and the timeout expired, returnsnull. - Since:
- Valkey 7.0 and above.
- See Also:
- valkey.io for details.
-
blmpop
public <ArgType> T blmpop(@NonNull @NonNull ArgType[] keys, @NonNull @NonNull ListDirection direction, double timeout)
Blocks the connection until it pops one element from the first non-empty list from the providedkeys.BLMPOPis the blocking variant of#lmpop(ArgType[], ListDirection).- Parameters:
keys- The list of providedkeynames.direction- The direction based on which elements are popped from - seeListDirection.timeout- The number of seconds to wait for a blocking operation to complete. A value of0will block indefinitely.- Returns:
- Command Response - A
Mapofkeynames arrays of popped elements.
If no member could be popped and the timeout expired, returnsnull. - Since:
- Valkey 7.0 and above.
- See Also:
- valkey.io for details.
-
bitpos
public <ArgType> T bitpos(@NonNull ArgType key, long bit)
Returns the position of the first bit matching the givenbitvalue.- Parameters:
key- The key of the string.bit- The bit value to match. The value must be0or1.- Returns:
- Command Response - The position of the first occurrence matching
bitin the binary value of the string held atkey. Ifbitis not found, a-1is returned. - See Also:
- valkey.io for details.
-
bitpos
public <ArgType> T bitpos(@NonNull ArgType key, long bit, long start)
Returns the position of the first bit matching the givenbitvalue. The offsetstartis a zero-based index, with0being the first byte of the list,1being the next byte and so on. These offsets can also be negative numbers indicating offsets starting at the end of the list, with-1being the last byte of the list,-2being the penultimate, and so on.- Parameters:
key- The key of the string.bit- The bit value to match. The value must be0or1.start- The starting offset.- Returns:
- Command Response - The position of the first occurrence beginning at the
startoffset of thebitin the binary value of the string held atkey. Ifbitis not found, a-1is returned. - See Also:
- valkey.io for details.
-
bitpos
public <ArgType> T bitpos(@NonNull ArgType key, long bit, long start, long end)
Returns the position of the first bit matching the givenbitvalue. The offsetsstartandendare zero-based indexes, with0being the first byte of the list,1being the next byte and so on. These offsets can also be negative numbers indicating offsets starting at the end of the list, with-1being the last byte of the list,-2being the penultimate, and so on.- Parameters:
key- The key of the string.bit- The bit value to match. The value must be0or1.start- The starting offset.end- The ending offset.- Returns:
- Command Response - The position of the first occurrence from the
startto theendoffsets of thebitin the binary value of the string held atkey. Ifbitis not found, a-1is returned. - See Also:
- valkey.io for details.
-
bitpos
public <ArgType> T bitpos(@NonNull ArgType key, long bit, long start, long end, @NonNull @NonNull BitmapIndexType offsetType)
Returns the position of the first bit matching the givenbitvalue. The offsetoffsetTypespecifies whether the offset is a BIT or BYTE. If BIT is specified,start==0andend==2means to look at the first three bits. If BYTE is specified,start==0andend==2means to look at the first three bytes The offsets are zero-based indexes, with0being the first element of the list,1being the next, and so on. These offsets can also be negative numbers indicating offsets starting at the end of the list, with-1being the last element of the list,-2being the penultimate, and so on.- Parameters:
key- The key of the string.bit- The bit value to match. The value must be0or1.start- The starting offset.end- The ending offset.offsetType- The index offset type. Could be eitherBitmapIndexType.BITorBitmapIndexType.BYTE.- Returns:
- Command Response - The position of the first occurrence from the
startto theendoffsets of thebitin the binary value of the string held atkey. Ifbitis not found, a-1is returned. - Since:
- Valkey 7.0 and above.
- See Also:
- valkey.io for details.
-
bitop
public <ArgType> T bitop(@NonNull @NonNull BitwiseOperation bitwiseOperation, @NonNull ArgType destination, @NonNull @NonNull ArgType[] keys)
Perform a bitwise operation between multiple keys (containing string values) and store the result in thedestination.- Parameters:
bitwiseOperation- 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.- Returns:
- Command Response - The size of the string stored in
destination. - See Also:
- valkey.io for details.
-
lmpop
public <ArgType> T lmpop(@NonNull @NonNull ArgType[] keys, @NonNull @NonNull ListDirection direction, @NonNull @NonNull java.lang.Long count)
Pops one or more elements from the first non-empty list from the providedkeys.- Parameters:
keys- An array of keys to lists.direction- The direction based on which elements are popped from - seeListDirection.count- The maximum number of popped elements.- Returns:
- Command Response - A
Mapofkeyname mapped arrays of popped elements. If no member could be popped, returnsnull. - Since:
- Valkey 7.0 and above.
- See Also:
- valkey.io for details.
-
lmpop
public <ArgType> T lmpop(@NonNull @NonNull ArgType[] keys, @NonNull @NonNull ListDirection direction)
Pops one element from the first non-empty list from the providedkeys.- Parameters:
keys- An array of keys to lists.direction- The direction based on which elements are popped from - seeListDirection.- Returns:
- Command Response - A
Mapofkeyname mapped array of the popped element. If no member could be popped, returnsnull. - Since:
- Valkey 7.0 and above.
- See Also:
- valkey.io for details.
-
lset
public <ArgType> T lset(@NonNull ArgType key, long index, @NonNull ArgType element)
Sets the list element atindextoelement.
The index is zero-based, so0means the first element,1the second element and so on. Negative indices can be used to designate elements starting at the tail of the list. Here,-1means the last element,-2means the penultimate and so forth.- Parameters:
key- The key of the list.index- The index of the element in the list to be set.- Returns:
- Command Response -
"OK"response on success. - See Also:
- valkey.io for details.
-
lmove
public <ArgType> T lmove(@NonNull ArgType source, @NonNull ArgType destination, @NonNull @NonNull ListDirection whereFrom, @NonNull @NonNull ListDirection whereTo)
Atomically pops and removes the left/right-most element to the list stored atsourcedepending onwhereFrom, and pushes the element at the first/last element of the list stored atdestinationdepending onwhereFrom.- Parameters:
source- The key to the source list.destination- The key to the destination list.whereFrom- TheListDirectionthe element should be removed from.whereTo- TheListDirectionthe element should be added to.- Returns:
- Command Response - The popped element or
nullifsourcedoes not exist. - Since:
- Valkey 6.2.0 and above.
- See Also:
- valkey.io for details.
-
blmove
public <ArgType> T blmove(@NonNull ArgType source, @NonNull ArgType destination, @NonNull @NonNull ListDirection whereFrom, @NonNull @NonNull ListDirection whereTo, double timeout)
Blocks the connection until it atomically pops and removes the left/right-most element to the list stored atsourcedepending onwhereFrom, and pushes the element at the first/last element of the list stored atdestinationdepending onwhereFrom.
BLMoveis the blocking variant of#lmove(ArgType, ArgType, ListDirection, ListDirection).- Parameters:
source- The key to the source list.destination- The key to the destination list.whereFrom- TheListDirectionthe element should be removed from.whereTo- TheListDirectionthe element should be added to.timeout- The number of seconds to wait for a blocking operation to complete. A value of0will block indefinitely.- Returns:
- Command Response - The popped element or
nullifsourcedoes not exist or if the operation timed-out. - Since:
- Valkey 6.2.0 and above.
- See Also:
- valkey.io for details.
-
srandmember
public <ArgType> T srandmember(@NonNull ArgType key)
Returns a random element from the set value stored atkey.- Parameters:
key- The key from which to retrieve the set member.- Returns:
- Command Response - A random element from the set, or
nullifkeydoes not exist. - See Also:
- valkey.io for details.
-
srandmember
public <ArgType> T srandmember(@NonNull ArgType key, long count)
Returns random elements from the set value stored atkey.- Parameters:
key- The key from which to retrieve the set members.count- The number of elements to return.
Ifcountis positive, returns unique elements.
If negative, allows for duplicates.- Returns:
- Command Response - An
arrayof elements from the set, or an emptyarrayifkeydoes not exist. - See Also:
- valkey.io for details.
-
spop
public <ArgType> T spop(@NonNull ArgType key)
Removes and returns one random member from the set stored atkey.- Parameters:
key- The key of the set.- Returns:
- Command Response - The value of the popped member.
Ifkeydoes not exist,nullwill be returned. - See Also:
- valkey.io for details.
-
spopCount
public <ArgType> T spopCount(@NonNull ArgType key, long count)
Removes and returns up tocountrandom members from the set stored atkey, depending on the set's length.- Parameters:
key- The key of the set.count- The count of the elements to pop from the set.- Returns:
- Command Response - A
Setof popped elements will be returned depending on the set's length.
Ifkeydoes not exist, an emptySetwill be returned. - See Also:
- valkey.io for details.
-
bitfield
public <ArgType> T bitfield(@NonNull ArgType key, @NonNull @NonNull BitFieldOptions.BitFieldSubCommands[] subCommands)
Reads or modifies the array of bits representing the string that is held atkeybased on the specifiedsubCommands.- Parameters:
key- The key of the string.subCommands- The subCommands to be performed on the binary value of the string atkey, which could be any of the following:- Returns:
- Command Response - An
arrayof results from the executed subcommands.BitFieldOptions.BitFieldGetreturns the value inBitFieldOptions.OffsetorBitFieldOptions.OffsetMultiplier.BitFieldOptions.BitFieldSetreturns the old value inBitFieldOptions.OffsetorBitFieldOptions.OffsetMultiplier.BitFieldOptions.BitFieldIncrbyreturns the new value inBitFieldOptions.OffsetorBitFieldOptions.OffsetMultiplier.BitFieldOptions.BitFieldOverflowdetermines the behaviour ofSETandINCRBYwhen an overflow occurs.OVERFLOWdoes not return a value and does not contribute a value to the array response.
- See Also:
- valkey.io for details.
-
bitfieldReadOnly
public <ArgType> T bitfieldReadOnly(@NonNull ArgType key, @NonNull @NonNull BitFieldOptions.BitFieldReadOnlySubCommands[] subCommands)
Reads the array of bits representing the string that is held atkeybased on the specifiedsubCommands.
This command is routed depending on the client'sReadFromstrategy.- Parameters:
key- The key of the string.subCommands- TheGETsubCommands to be performed.- Returns:
- Command Response - An
arrayof results from theGETsubcommands. - Since:
- Valkey 6.0 and above
- See Also:
- valkey.io for details.
-
functionFlush
public T functionFlush()
Deletes all function libraries.- Returns:
- Command Response -
"OK"response on success. - Since:
- Valkey 7.0 and above.
- See Also:
- valkey.io for details.
-
functionFlush
public T functionFlush(@NonNull @NonNull FlushMode mode)
Deletes all function libraries.- Parameters:
mode- The flushing mode, could be eitherFlushMode.SYNCorFlushMode.ASYNC.- Returns:
- Command Response -
"OK"response on success. - Since:
- Valkey 7.0 and above.
- See Also:
- valkey.io for details.
-
functionDelete
public <ArgType> T functionDelete(@NonNull ArgType libName)
Deletes a library and all its functions.- Parameters:
libName- The library name to delete.- Returns:
- Command Response -
"OK"response on success. - Since:
- Valkey 7.0 and above.
- See Also:
- valkey.io for details.
-
lcs
public <ArgType> T lcs(@NonNull ArgType key1, @NonNull ArgType key2)
Returns all the longest common subsequences combined between strings stored atkey1andkey2.- Parameters:
key1- The key that stores the first string.key2- The key that stores the second string.- Returns:
- Command Response - A
Stringcontaining all the longest common subsequences combined between the 2 strings. An emptyString/GlideStringis returned if the keys do not exist or have no common subsequences. - Since:
- Valkey 7.0 and above.
- See Also:
- valkey.io for details.
-
lcsLen
public <ArgType> T lcsLen(@NonNull ArgType key1, @NonNull ArgType key2)
Returns the total length of all the longest common subsequences between strings stored atkey1andkey2.- Parameters:
key1- The key that stores the first string.key2- The key that stores the second string.- Returns:
- Command Response - The total length of all the longest common subsequences between the 2 strings.
- Since:
- Valkey 7.0 and above.
- See Also:
- valkey.io for details.
-
publish
public <ArgType> T publish(@NonNull ArgType message, @NonNull ArgType channel)
Publishes message on pubsub channel.- Parameters:
message- The message to publish.channel- The channel to publish the message on.- Returns:
- Command response - The number of clients that received the message.
- See Also:
- valkey.io for details.
-
pubsubChannels
public T pubsubChannels()
Lists the currently active channels.- Returns:
- Command response - An
Arrayof all active channels. - See Also:
- valkey.io for details.
-
pubsubChannels
public <ArgType> T pubsubChannels(@NonNull ArgType pattern)
Lists the currently active channels.- Parameters:
pattern- A glob-style pattern to match active channels.- Returns:
- Command response - An
Arrayof currently active channels matching the given pattern. - See Also:
- valkey.io for details.
-
pubsubNumPat
public T pubsubNumPat()
Returns the number of unique patterns that are subscribed to by clients.- Returns:
- Command response - The number of unique patterns.
- See Also:
- valkey.io for details.
-
pubsubNumSub
public <ArgType> T pubsubNumSub(@NonNull @NonNull ArgType[] channels)
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.- Returns:
- Command response - A
Mapwhere keys are the channel names and values are the numbers of subscribers. - See Also:
- valkey.io for details.
-
sunion
public <ArgType> T sunion(@NonNull @NonNull ArgType[] keys)
Gets the union of all the given sets.- Parameters:
keys- The keys of the sets.- Returns:
- Command Response - A
Setof members which are present in at least one of the given sets. If none of the sets exist, an empty set will be returned. - See Also:
- valkey.io for details.
-
lcsIdx
public <ArgType> T lcsIdx(@NonNull ArgType key1, @NonNull ArgType key2)
Returns the indices and length of the longest common subsequence between strings stored atkey1andkey2.- Parameters:
key1- The key that stores the first string.key2- The key that stores the second string.- Returns:
- Command Response - A
Mapcontaining the indices of the longest common subsequence between the 2 strings and the total length of all 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
Long. - "matches" is mapped to a three dimensional
Longarray that stores pairs of indices that represent the location of the common subsequences in the strings held bykey1andkey2.
StringBaseCommands.lcsIdx(String, String)for more details. - "len" is mapped to the total length of the all longest common subsequences between
the 2 strings stored as
- Since:
- Valkey 7.0 and above.
- See Also:
- valkey.io for details.
-
lcsIdx
public <ArgType> T lcsIdx(@NonNull ArgType key1, @NonNull ArgType key2, long minMatchLen)
Returns the indices and the total length of all the longest common subsequences between strings stored atkey1andkey2.- Parameters:
key1- The key that stores the first string.key2- The key that stores the second string.minMatchLen- The minimum length of matches to include in the result.- Returns:
- Command Response - A
Mapcontaining the indices of the longest common subsequence between the 2 strings and the total length of all 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
Long. This value doesn't count towards theminMatchLenfilter. - "matches" is mapped to a three dimensional
Longarray that stores pairs of indices that represent the location of the common subsequences in the strings held bykey1andkey2.
StringBaseCommands.lcsIdx(String, String, long)for more details. - "len" is mapped to the total length of the all longest common subsequences between
the 2 strings stored as
- Since:
- Valkey 7.0 and above.
- See Also:
- valkey.io for details.
-
lcsIdxWithMatchLen
public <ArgType> T lcsIdxWithMatchLen(@NonNull ArgType key1, @NonNull ArgType key2)
Returns the indices and lengths of the longest common subsequences between strings stored atkey1andkey2.- Parameters:
key1- The key that stores the first string.key2- The key that stores the second string.- Returns:
- Command Response - A
Mapcontaining the indices of the longest common subsequence 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
Long. - "matches" is mapped to a three dimensional array that stores pairs of indices that
represent the location of the common subsequences in the strings held by
key1andkey2and the match length.
StringBaseCommands.lcsIdxWithMatchLen(String, String)for more details. - "len" is mapped to the total length of the all longest common subsequences between
the 2 strings stored as
- Since:
- Valkey 7.0 and above.
- See Also:
- valkey.io for details.
-
lcsIdxWithMatchLen
public <ArgType> T lcsIdxWithMatchLen(@NonNull ArgType key1, @NonNull ArgType key2, long minMatchLen)
Returns the indices and lengths of the longest common subsequences between strings stored atkey1andkey2.- Parameters:
key1- The key that stores the first string.key2- The key that stores the second string.minMatchLen- The minimum length of matches to include in the result.- Returns:
- Command Response - A
Mapcontaining the indices of the longest common subsequence 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
Long. - "matches" is mapped to a three dimensional array that stores pairs of indices that
represent the location of the common subsequences in the strings held by
key1andkey2and the match length.
StringBaseCommands.lcsIdxWithMatchLen(String, String, long)for more details. - "len" is mapped to the total length of the all longest common subsequences between
the 2 strings stored as
- Since:
- Valkey 7.0 and above.
- See Also:
- valkey.io for details.
-
sort
public <ArgType> T sort(@NonNull ArgType key)
Sorts the elements in the list, set, or sorted set atkeyand returns the result.
Thesortcommand 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(ArgType, ArgType).- Parameters:
key- The key of the list, set, or sorted set to be sorted.- Returns:
- Command Response - An
Arrayof sorted elements. - See Also:
- valkey.io for details.
-
sort
public <ArgType> T sort(@NonNull ArgType key, @NonNull @NonNull SortOptions sortOptions)
Sorts the elements in the list, set, or sorted set atkeyand returns the result. Thesortcommand 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(ArgType, ArgType, SortOptions).- Parameters:
key- The key of the list, set, or sorted set to be sorted.sortOptions- TheSortOptions.- Returns:
- Command Response - An
Arrayof sorted elements. - See Also:
- valkey.io for details.
-
sortReadOnly
public <ArgType> T sortReadOnly(@NonNull ArgType key)
Sorts the elements in the list, set, or sorted set atkeyand returns the result.
ThesortReadOnlycommand can be used to sort elements based on different criteria and apply transformations on sorted elements.- Parameters:
key- The key of the list, set, or sorted set to be sorted.- Returns:
- Command Response - An
Arrayof sorted elements. - Since:
- Valkey 7.0 and above.
- See Also:
- valkey.io for details.
-
sortReadOnly
public <ArgType> T sortReadOnly(@NonNull ArgType key, @NonNull @NonNull SortOptions sortOptions)
Sorts the elements in the list, set, or sorted set atkeyand returns the result. ThesortReadOnlycommand can be used to sort elements based on different criteria and apply transformations on sorted elements.- Parameters:
key- The key of the list, set, or sorted set to be sorted.sortOptions- TheSortOptions.- Returns:
- Command Response - An
Arrayof sorted elements. - Since:
- Valkey 7.0 and above.
- See Also:
- valkey.io for details.
-
sortStore
public <ArgType> T sortStore(@NonNull ArgType key, @NonNull ArgType destination)
Sorts the elements in the list, set, or sorted set atkeyand stores the result indestination. Thesortcommand can be used to sort elements based on different criteria, 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(ArgType)or#sortReadOnly(ArgType).- Parameters:
key- The key of the list, set, or sorted set to be sorted.destination- The key where the sorted result will be stored.- Returns:
- Command Response - The number of elements in the sorted key stored at
destination. - See Also:
- valkey.io for details.
-
sortStore
public <ArgType> T sortStore(@NonNull ArgType key, @NonNull ArgType destination, @NonNull @NonNull SortOptions sortOptions)
Sorts the elements in the list, set, or sorted set atkeyand stores the result indestination. Thesortcommand can be used to sort elements based on different criteria, 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(ArgType, SortOptions).- Parameters:
key- The key of the list, set, or sorted set to be sorted.sortOptions- TheSortOptions.destination- The key where the sorted result will be stored.- Returns:
- Command Response - The number of elements in the sorted key stored at
destination. - See Also:
- valkey.io for details.
-
geosearch
public <ArgType> T geosearch(@NonNull ArgType key, @NonNull @NonNull GeoSearchOrigin.SearchOrigin searchFrom, @NonNull @NonNull GeoSearchShape searchBy)
Returns the members of a sorted set populated with geospatial information using#geoadd(ArgType, Map), 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:GeoSearchOrigin.MemberOriginto use the position of the given existing member in the sorted set.GeoSearchOrigin.CoordOriginto use the given longitude and latitude coordinates.
searchBy- The query's shape options:GeoSearchShape(double, GeoUnit)to search inside circular area according to given radius.GeoSearchShape(double, double, GeoUnit)to search inside an axis-aligned rectangle, determined by height and width.
- Returns:
- Command Response - An
arrayof matched member names. - Since:
- Valkey 6.2.0 and above.
- See Also:
- valkey.io for more details.
-
geosearch
public <ArgType> T geosearch(@NonNull ArgType key, @NonNull @NonNull GeoSearchOrigin.SearchOrigin searchFrom, @NonNull @NonNull GeoSearchShape searchBy, @NonNull @NonNull GeoSearchResultOptions resultOptions)
Returns the members of a sorted set populated with geospatial information using#geoadd(ArgType, Map), 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:GeoSearchOrigin.MemberOriginto use the position of the given existing member in the sorted set.GeoSearchOrigin.CoordOriginto use the given longitude and latitude coordinates.
searchBy- The query's shape options:GeoSearchShape(double, GeoUnit)to search inside circular area according to given radius.GeoSearchShape(double, double, GeoUnit)to search inside an axis-aligned rectangle, determined by height and width.
resultOptions- Optional inputs for sorting/limiting the results. See -GeoSearchResultOptions- Returns:
- Command Response - An
arrayof matched member names. - Since:
- Valkey 6.2.0 and above.
- See Also:
- valkey.io for more details.
-
geosearch
public <ArgType> T geosearch(@NonNull ArgType key, @NonNull @NonNull GeoSearchOrigin.SearchOrigin searchFrom, @NonNull @NonNull GeoSearchShape searchBy, @NonNull @NonNull GeoSearchOptions options)
Returns the members of a sorted set populated with geospatial information using#geoadd(ArgType, Map), 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:GeoSearchOrigin.MemberOriginto use the position of the given existing member in the sorted set.GeoSearchOrigin.CoordOriginto use the given longitude and latitude coordinates.
searchBy- The query's shape options:GeoSearchShape(double, GeoUnit)to search inside circular area according to given radius.GeoSearchShape(double, double, GeoUnit)to search inside an axis-aligned rectangle, determined by height and width.
options- The optional inputs to request additional information.- Returns:
- Command Response - A 2D
arrayof arrays where each sub-array represents a single item in the following order:- The member (location) name.
- The distance from the center as a
Double, in the same unit specified forsearchBy. - The geohash of the location as a
Long. - The coordinates as a two item
arrayofDouble.
- Since:
- Valkey 6.2.0 and above.
- See Also:
- valkey.io for more details.
-
geosearch
public <ArgType> T geosearch(@NonNull ArgType key, @NonNull @NonNull GeoSearchOrigin.SearchOrigin searchFrom, @NonNull @NonNull GeoSearchShape searchBy, @NonNull @NonNull GeoSearchOptions options, @NonNull @NonNull GeoSearchResultOptions resultOptions)
Returns the members of a sorted set populated with geospatial information using#geoadd(ArgType, Map), 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:GeoSearchOrigin.MemberOriginto use the position of the given existing member in the sorted set.GeoSearchOrigin.CoordOriginto use the given longitude and latitude coordinates.
searchBy- The query's shape options:GeoSearchShape(double, GeoUnit)to search inside circular area according to given radius.GeoSearchShape(double, double, GeoUnit)to search inside an axis-aligned rectangle, determined by height and width.
options- The optional inputs to request additional information.resultOptions- Optional inputs for sorting/limiting the results. See -GeoSearchResultOptions- Returns:
- Command Response - A 2D
arrayof arrays where each sub-array represents a single item in the following order:- The member (location) name.
- The distance from the center as a
Double, in the same unit specified forsearchBy. - The geohash of the location as a
Long. - The coordinates as a two item
arrayofDouble.
- Since:
- Valkey 6.2.0 and above.
- See Also:
- valkey.io for more details.
-
geosearchstore
public <ArgType> T geosearchstore(@NonNull ArgType destination, @NonNull ArgType source, @NonNull @NonNull GeoSearchOrigin.SearchOrigin searchFrom, @NonNull @NonNull GeoSearchShape searchBy)
Searches for members in a sorted set stored atsourcerepresenting geospatial data within a circular or rectangular area and stores the result indestination. Ifdestinationalready exists, it is overwritten. Otherwise, a new sorted set will be created. To get the result directly, see `#geosearch(ArgType, SearchOrigin, GeoSearchShape).- Parameters:
destination- The key of the destination sorted set.source- The key of the source sorted set.searchFrom- The query's center point options, could be one of:GeoSearchOrigin.MemberOriginto use the position of the given existing member in the sorted set.GeoSearchOrigin.CoordOriginto use the given longitude and latitude coordinates.
searchBy- The query's shape options:GeoSearchShape(double, GeoUnit)to search inside circular area according to given radius.GeoSearchShape(double, double, GeoUnit)to search inside an axis-aligned rectangle, determined by height and width.
- Returns:
- Command Response - The number of elements in the resulting set.
- Since:
- Valkey 6.2.0 and above.
- See Also:
- valkey.io for more details.
-
geosearchstore
public <ArgType> T geosearchstore(@NonNull ArgType destination, @NonNull ArgType source, @NonNull @NonNull GeoSearchOrigin.SearchOrigin searchFrom, @NonNull @NonNull GeoSearchShape searchBy, @NonNull @NonNull GeoSearchResultOptions resultOptions)
Searches for members in a sorted set stored atsourcerepresenting geospatial data within a circular or rectangular area and stores the result indestination. Ifdestinationalready exists, it is overwritten. Otherwise, a new sorted set will be created. To get the result directly, see `#geosearch(ArgType, SearchOrigin, GeoSearchShape, GeoSearchResultOptions).- Parameters:
destination- The key of the destination sorted set.source- The key of the source sorted set.searchFrom- The query's center point options, could be one of:GeoSearchOrigin.MemberOriginto use the position of the given existing member in the sorted set.GeoSearchOrigin.CoordOriginto use the given longitude and latitude coordinates.
searchBy- The query's shape options:GeoSearchShape(double, GeoUnit)to search inside circular area according to given radius.GeoSearchShape(double, double, GeoUnit)to search inside an axis-aligned rectangle, determined by height and width.
resultOptions- Optional inputs for sorting/limiting the results. See -GeoSearchResultOptions- Returns:
- Command Response - The number of elements in the resulting set.
- Since:
- Valkey 6.2.0 and above.
- See Also:
- valkey.io for more details.
-
geosearchstore
public <ArgType> T geosearchstore(@NonNull ArgType destination, @NonNull ArgType source, @NonNull @NonNull GeoSearchOrigin.SearchOrigin searchFrom, @NonNull @NonNull GeoSearchShape searchBy, @NonNull @NonNull GeoSearchStoreOptions options)
Searches for members in a sorted set stored atsourcerepresenting geospatial data within a circular or rectangular area and stores the result indestination. Ifdestinationalready exists, it is overwritten. Otherwise, a new sorted set will be created. To get the result directly, see `#geosearch(ArgType, SearchOrigin, GeoSearchShape, GeoSearchOptions).- Parameters:
destination- The key of the destination sorted set.source- The key of the source sorted set.searchFrom- The query's center point options, could be one of:GeoSearchOrigin.MemberOriginto use the position of the given existing member in the sorted set.GeoSearchOrigin.CoordOriginto use the given longitude and latitude coordinates.
searchBy- The query's shape options:GeoSearchShape(double, GeoUnit)to search inside circular area according to given radius.GeoSearchShape(double, double, GeoUnit)to search inside an axis-aligned rectangle, determined by height and width.
options- The optional inputs to request additional information.- Returns:
- Command Response - The number of elements in the resulting set.
- Since:
- Valkey 6.2.0 and above.
- See Also:
- valkey.io for more details.
-
geosearchstore
public <ArgType> T geosearchstore(@NonNull ArgType destination, @NonNull ArgType source, @NonNull @NonNull GeoSearchOrigin.SearchOrigin searchFrom, @NonNull @NonNull GeoSearchShape searchBy, @NonNull @NonNull GeoSearchStoreOptions options, @NonNull @NonNull GeoSearchResultOptions resultOptions)
Searches for members in a sorted set stored atsourcerepresenting geospatial data within a circular or rectangular area and stores the result indestination. Ifdestinationalready exists, it is overwritten. Otherwise, a new sorted set will be created. To get the result directly, see `#geosearch(ArgType, SearchOrigin, GeoSearchShape, GeoSearchOptions, GeoSearchResultOptions).- Parameters:
destination- The key of the destination sorted set.source- The key of the source sorted set.searchFrom- The query's center point options, could be one of:GeoSearchOrigin.MemberOriginto use the position of the given existing member in the sorted set.GeoSearchOrigin.CoordOriginto use the given longitude and latitude coordinates.
searchBy- The query's shape options:GeoSearchShape(double, GeoUnit)to search inside circular area according to given radius.GeoSearchShape(double, double, GeoUnit)to search inside an axis-aligned rectangle, determined by height and width.
options- The optional inputs to request additional information.resultOptions- Optional inputs for sorting/limiting the results. See -GeoSearchResultOptions- Returns:
- Command Response - The number of elements in the resulting set.
- Since:
- Valkey 6.2.0 and above.
- See Also:
- valkey.io for more details.
-
sscan
public <ArgType> T sscan(@NonNull ArgType key, @NonNull ArgType cursor)
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.- Returns:
- Command Response - An
ArrayofObjects. The first element is always thecursorfor the next iteration of results."0"will be thecursorreturned on the last iteration of the set. The second element is always anArrayof the subset of the set held inkey. - See Also:
- valkey.io for details.
-
sscan
public <ArgType> T sscan(@NonNull ArgType key, @NonNull ArgType cursor, @NonNull @NonNull SScanOptions sScanOptions)
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.sScanOptions- TheSScanOptions.- Returns:
- Command Response - An
ArrayofObjects. The first element is always thecursorfor the next iteration of results."0"will be thecursorreturned on the last iteration of the set. The second element is always anArrayof the subset of the set held inkey. - See Also:
- valkey.io for details.
-
zscan
public <ArgType> T zscan(@NonNull ArgType key, @NonNull ArgType cursor)
Iterates incrementally over a sorted set.- Parameters:
key- The key of the sorted set.cursor- The cursor that points to the next iteration of results. A value of"0"indicates the start of the search.- Returns:
- Command Response - An
ArrayofObjects. The first element is always thecursorfor the next iteration of results."0"will be thecursorreturned on the last iteration of the sorted set. The second element is always anArrayof the subset of the sorted set held inkey. The array in the second element is always a flattened series ofStringpairs, where the value is at even indices and the score is at odd indices. - See Also:
- valkey.io for details.
-
zscan
public <ArgType> T zscan(@NonNull ArgType key, @NonNull ArgType cursor, @NonNull @NonNull ZScanOptions zScanOptions)
Iterates incrementally over a sorted set.- Parameters:
key- The key of the sorted set.cursor- The cursor that points to the next iteration of results. A value of"0"indicates the start of the search.zScanOptions- TheZScanOptions.- Returns:
- Command Response - An
ArrayofObjects. The first element is always thecursorfor the next iteration of results."0"will be thecursorreturned on the last iteration of the sorted set. The second element is always anArrayof the subset of the sorted set held inkey. The array in the second element is a flattened series ofStringpairs, where the value is at even indices and the score is at odd indices. IfZScanOptions.ZScanOptionsBuilder.noScores(boolean)is totrue, the second element will only contain the members without scores. - See Also:
- valkey.io for details.
-
hscan
public <ArgType> T hscan(@NonNull ArgType key, @NonNull ArgType cursor)
Iterates fields of Hash types and their associated values.- Parameters:
key- The key of the hash.cursor- The cursor that points to the next iteration of results. A value of"0"indicates the start of the search.- Returns:
- Command Response - An
ArrayofObjects. The first element is always thecursorfor the next iteration of results."0"will be thecursorreturned on the last iteration of the result. The second element is always anArrayof the subset of the hash held inkey. The array in the second element is always a flattened series ofStringpairs, where the key is at even indices and the value is at odd indices. - See Also:
- valkey.io for details.
-
hscan
public <ArgType> T hscan(@NonNull ArgType key, @NonNull ArgType cursor, @NonNull @NonNull HScanOptions hScanOptions)
Iterates fields of Hash types and their associated values.- Parameters:
key- The key of the hash.cursor- The cursor that points to the next iteration of results. A value of"0"indicates the start of the search.hScanOptions- TheHScanOptions.- Returns:
- Command Response - An
ArrayofObjects. The first element is always thecursorfor the next iteration of results."0"will be thecursorreturned on the last iteration of the result. The second element is always anArrayof the subset of the hash held inkey. The array in the second element is a flattened series ofStringpairs, where the key is at even indices and the value is at odd indices. IfHScanOptions.HScanOptionsBuilder.noValues(boolean)is set totrue, the second element will only contain the fields without the values. - See Also:
- valkey.io for details.
-
wait
public T wait(long numReplicas, long timeout)
Returns the number of replicas that acknowledged the write commands sent by the current client before this command, both in the case where the specified number of replicas are reached, or when the timeout is reached.- Parameters:
numReplicas- The number of replicas to reach.timeout- The timeout value specified in milliseconds.- Returns:
- Command Response - The number of replicas reached by all the writes performed in the context of the current connection.
- See Also:
- valkey.io for details.
-
buildCommand
protected CommandRequestOuterClass.Command buildCommand(CommandRequestOuterClass.RequestType requestType)
Build protobufCommandRequestOuterClass.Commandobject for given command and arguments.
-
buildCommand
protected CommandRequestOuterClass.Command buildCommand(CommandRequestOuterClass.RequestType requestType, CommandRequestOuterClass.Command.ArgsArray args)
Build protobufCommandRequestOuterClass.Commandobject for given command and arguments.
-
buildCommand
protected CommandRequestOuterClass.Command buildCommand(CommandRequestOuterClass.RequestType requestType, ArgsBuilder argsBuilder)
Build protobufCommandRequestOuterClass.Commandobject for given command and arguments.
-
emptyArgs
protected CommandRequestOuterClass.Command.ArgsArray emptyArgs()
Build protobufCommandRequestOuterClass.Command.ArgsArrayobject for empty arguments.
-
createArray
@SafeVarargs protected final <ArgType> ArgType[] createArray(ArgType... args)
Helper function for creating generic type ("ArgType") array
-
-