Class GlideClient
- java.lang.Object
-
- glide.api.BaseClient
-
- glide.api.GlideClient
-
- All Implemented Interfaces:
BitmapBaseCommands,ConnectionManagementCommands,GenericBaseCommands,GenericCommands,GeospatialIndicesBaseCommands,HashBaseCommands,HyperLogLogBaseCommands,ListBaseCommands,PubSubBaseCommands,ScriptingAndFunctionsBaseCommands,ScriptingAndFunctionsCommands,ServerManagementCommands,SetBaseCommands,SortedSetBaseCommands,StreamBaseCommands,StringBaseCommands,TransactionsBaseCommands,TransactionsCommands,java.lang.AutoCloseable
public class GlideClient extends BaseClient implements GenericCommands, ServerManagementCommands, ConnectionManagementCommands, ScriptingAndFunctionsCommands, TransactionsCommands
Client used for connection to standalone servers.
UsecreateClient(glide.api.models.configuration.GlideClientConfiguration)to request a client.- See Also:
full documentation refer to Valkey Glide Wiki.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class glide.api.BaseClient
BaseClient.ClientBuilder, BaseClient.ResponseFlags
-
-
Field Summary
-
Fields inherited from class glide.api.BaseClient
commandManager, connectionManager, COUNT_FOR_LIST_VALKEY_API, COUNT_VALKEY_API, EMPTY_GLIDE_STRING_ARRAY, IDX_COMMAND_STRING, LCS_MATCHES_RESULT_KEY, LEN_VALKEY_API, LIMIT_VALKEY_API, messageHandler, MINMATCHLEN_COMMAND_STRING, OK, REPLACE_VALKEY_API, SET_LIMIT_VALKEY_API, subscriptionConfiguration, WITH_SCORE_VALKEY_API, WITH_SCORES_VALKEY_API, WITH_VALUES_VALKEY_API, WITHMATCHLEN_COMMAND_STRING
-
Fields inherited from interface glide.api.commands.GenericBaseCommands
DB_VALKEY_API
-
Fields inherited from interface glide.api.commands.HashBaseCommands
FIELDS_VALKEY_API
-
Fields inherited from interface glide.api.commands.ServerManagementCommands
VERSION_VALKEY_API
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedGlideClient(BaseClient.ClientBuilder builder)Constructor using ClientParams from BaseClient.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description java.util.concurrent.CompletableFuture<java.lang.String>clientGetName()Gets the name of the current connection.java.util.concurrent.CompletableFuture<java.lang.Long>clientId()Gets the current connection id.java.util.concurrent.CompletableFuture<java.util.Map<java.lang.String,java.lang.String>>configGet(@NonNull java.lang.String[] parameters)Get the values of configuration parameters.
Starting from server version 7, command supports multiple parameters.java.util.concurrent.CompletableFuture<java.lang.String>configResetStat()Resets the statistics reported by the server using the INFO and LATENCY HISTOGRAM commands.java.util.concurrent.CompletableFuture<java.lang.String>configRewrite()Rewrites the configuration file with the current configuration.java.util.concurrent.CompletableFuture<java.lang.String>configSet(@NonNull java.util.Map<java.lang.String,java.lang.String> parameters)Sets configuration parameters to the specified values.
Starting from server version 7, command supports multiple parameters.static java.util.concurrent.CompletableFuture<GlideClient>createClient(@NonNull GlideClientConfiguration config)Creates a newGlideClientinstance and establishes a connection to a standalone Valkeyjava.util.concurrent.CompletableFuture<java.lang.Object>customCommand(@NonNull GlideString[] args)Executes a single command, without checking inputs.java.util.concurrent.CompletableFuture<java.lang.Object>customCommand(@NonNull java.lang.String[] args)Executes a single command, without checking inputs.java.util.concurrent.CompletableFuture<java.lang.Long>dbsize()Returns the number of keys in the currently selected database.java.util.concurrent.CompletableFuture<GlideString>echo(@NonNull GlideString message)Echoes the providedmessageback.java.util.concurrent.CompletableFuture<java.lang.String>echo(@NonNull java.lang.String message)Echoes the providedmessageback.java.util.concurrent.CompletableFuture<java.lang.Object[]>exec(@NonNull Batch batch, boolean raiseOnError)Executes a batch by processing the queued commands.java.util.concurrent.CompletableFuture<java.lang.Object[]>exec(@NonNull Batch batch, boolean raiseOnError, @NonNull BatchOptions options)Executes a batch by processing the queued commands with additional options.java.util.concurrent.CompletableFuture<java.lang.Object[]>exec(@NonNull Transaction transaction)Deprecated.java.util.concurrent.CompletableFuture<java.lang.Object>fcall(@NonNull GlideString function)Invokes a previously loaded function.
This command is routed to primary nodes only.
To route to a replica please refer toScriptingAndFunctionsCommands.fcallReadOnly(java.lang.String).java.util.concurrent.CompletableFuture<java.lang.Object>fcall(@NonNull java.lang.String function)Invokes a previously loaded function.
This command is routed to primary nodes only.
To route to a replica please refer toScriptingAndFunctionsCommands.fcallReadOnly(java.lang.String).java.util.concurrent.CompletableFuture<java.lang.Object>fcallReadOnly(@NonNull GlideString function)Invokes a previously loaded read-only function.
This command is routed depending on the client'sReadFromstrategy.java.util.concurrent.CompletableFuture<java.lang.Object>fcallReadOnly(@NonNull java.lang.String function)Invokes a previously loaded read-only function.
This command is routed depending on the client'sReadFromstrategy.java.util.concurrent.CompletableFuture<java.lang.String>flushall()Deletes all the keys of all the existing databases.java.util.concurrent.CompletableFuture<java.lang.String>flushall(@NonNull FlushMode mode)Deletes all the keys of all the existing databases.java.util.concurrent.CompletableFuture<java.lang.String>flushdb()Deletes all the keys of the currently selected database.java.util.concurrent.CompletableFuture<java.lang.String>flushdb(@NonNull FlushMode mode)Deletes all the keys of the currently selected database.java.util.concurrent.CompletableFuture<java.lang.String>functionDelete(@NonNull GlideString libName)Deletes a library and all its functions.java.util.concurrent.CompletableFuture<java.lang.String>functionDelete(@NonNull java.lang.String libName)Deletes a library and all its functions.java.util.concurrent.CompletableFuture<byte[]>functionDump()Returns the serialized payload of all loaded libraries.java.util.concurrent.CompletableFuture<java.lang.String>functionFlush()Deletes all function libraries.java.util.concurrent.CompletableFuture<java.lang.String>functionFlush(@NonNull FlushMode mode)Deletes all function libraries.java.util.concurrent.CompletableFuture<java.lang.String>functionKill()Kills a function that is currently executing.
FUNCTION KILLterminates read-only functions only.java.util.concurrent.CompletableFuture<java.util.Map<java.lang.String,java.lang.Object>[]>functionList(boolean withCode)Returns information about the functions and libraries.java.util.concurrent.CompletableFuture<java.util.Map<java.lang.String,java.lang.Object>[]>functionList(@NonNull java.lang.String libNamePattern, boolean withCode)Returns information about the functions and libraries.java.util.concurrent.CompletableFuture<java.util.Map<GlideString,java.lang.Object>[]>functionListBinary(boolean withCode)Returns information about the functions and libraries.java.util.concurrent.CompletableFuture<java.util.Map<GlideString,java.lang.Object>[]>functionListBinary(@NonNull GlideString libNamePattern, boolean withCode)Returns information about the functions and libraries.java.util.concurrent.CompletableFuture<GlideString>functionLoad(@NonNull GlideString libraryCode, boolean replace)Loads a library to Valkey.java.util.concurrent.CompletableFuture<java.lang.String>functionLoad(@NonNull java.lang.String libraryCode, boolean replace)Loads a library to Valkey.java.util.concurrent.CompletableFuture<java.lang.String>functionRestore(byte @NonNull [] payload)Restores libraries from the serialized payload returned byScriptingAndFunctionsCommands.functionDump().java.util.concurrent.CompletableFuture<java.lang.String>functionRestore(byte @NonNull [] payload, @NonNull FunctionRestorePolicy policy)Restores libraries from the serialized payload returned byScriptingAndFunctionsCommands.functionDump()..java.util.concurrent.CompletableFuture<java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.Object>>>>functionStats()Returns information about the function that's currently running and information about the available execution engines.
FUNCTION STATSruns on all nodes of the server, including primary and replicas.java.util.concurrent.CompletableFuture<java.util.Map<java.lang.String,java.util.Map<GlideString,java.util.Map<GlideString,java.lang.Object>>>>functionStatsBinary()Returns information about the function that's currently running and information about the available execution engines.
FUNCTION STATSruns on all nodes of the server, including primary and replicas.java.util.concurrent.CompletableFuture<java.lang.String>info()Gets information and statistics about the server using theInfoOptions.Section.DEFAULToption.java.util.concurrent.CompletableFuture<java.lang.String>info(@NonNull InfoOptions.Section[] sections)Get information and statistics about the server.
Starting from server version 7, command supports multiple section arguments.java.util.concurrent.CompletableFuture<java.lang.Long>lastsave()ReturnsUNIX TIMEof the last DB save timestamp or startup timestamp if no save was made since then.java.util.concurrent.CompletableFuture<java.lang.String>lolwut()Displays a piece of generative computer art and the Valkey version.java.util.concurrent.CompletableFuture<java.lang.String>lolwut(int version)Displays a piece of generative computer art and the Valkey version.java.util.concurrent.CompletableFuture<java.lang.String>lolwut(int @NonNull [] parameters)Displays a piece of generative computer art and the Valkey version.java.util.concurrent.CompletableFuture<java.lang.String>lolwut(int version, int @NonNull [] parameters)Displays a piece of generative computer art and the Valkey version.java.util.concurrent.CompletableFuture<java.lang.String>ping()Pings the server.java.util.concurrent.CompletableFuture<GlideString>ping(@NonNull GlideString message)Pings the server.java.util.concurrent.CompletableFuture<java.lang.String>ping(@NonNull java.lang.String message)Pings the server.java.util.concurrent.CompletableFuture<java.lang.String>randomKey()Returns a random key from currently selected database.java.util.concurrent.CompletableFuture<GlideString>randomKeyBinary()Returns a random key from currently selected database.java.util.concurrent.CompletableFuture<java.lang.Object[]>scan(@NonNull GlideString cursor)Iterates incrementally over a database for matching keys.java.util.concurrent.CompletableFuture<java.lang.Object[]>scan(@NonNull GlideString cursor, @NonNull ScanOptions options)Iterates incrementally over a database for matching keys.java.util.concurrent.CompletableFuture<java.lang.Object[]>scan(@NonNull java.lang.String cursor)Iterates incrementally over a database for matching keys.java.util.concurrent.CompletableFuture<java.lang.Object[]>scan(@NonNull java.lang.String cursor, @NonNull ScanOptions options)Iterates incrementally over a database for matching keys.java.util.concurrent.CompletableFuture<java.lang.String>select(long index)Changes the currently selected database.java.util.concurrent.CompletableFuture<java.lang.String[]>time()Returns the server time.java.util.concurrent.CompletableFuture<java.lang.String>unwatch()Flushes all the previously watched keys for a transaction.-
Methods inherited from class glide.api.BaseClient
__enqueuePubSubMessage, append, append, bitcount, bitcount, bitcount, bitcount, bitcount, bitcount, bitcount, bitcount, bitfield, bitfield, bitfieldReadOnly, bitfieldReadOnly, bitop, bitop, bitpos, bitpos, bitpos, bitpos, bitpos, bitpos, bitpos, bitpos, blmove, blmove, blmpop, blmpop, blmpop, blmpop, blpop, blpop, brpop, brpop, buildCommandManager, buildConnectionManager, buildMessageHandler, bzmpop, bzmpop, bzmpop, bzmpop, bzpopmax, bzpopmax, bzpopmin, bzpopmin, close, copy, copy, copy, copy, copy, copy, copy, copy, createClient, decr, decr, decrBy, decrBy, del, del, dump, exists, exists, expire, expire, expire, expire, expireAt, expireAt, expireAt, expireAt, expiretime, expiretime, fcall, fcall, fcallReadOnly, fcallReadOnly, geoadd, geoadd, geoadd, geoadd, geodist, geodist, geodist, geodist, geohash, geohash, geopos, geopos, geosearch, geosearch, geosearch, geosearch, geosearch, geosearch, geosearch, geosearch, geosearchstore, geosearchstore, geosearchstore, geosearchstore, geosearchstore, geosearchstore, geosearchstore, geosearchstore, get, get, getbit, getbit, getClientInfo, getdel, getdel, getex, getex, getex, getex, getPubSubMessage, getrange, getrange, getStatistics, handleArrayOrNullResponse, handleArrayOrNullResponseBinary, handleArrayResponse, handleArrayResponseBinary, handleBinaryObjectOrNullResponse, handleBinaryStringMapOrNullResponse, handleBinaryStringMapResponse, handleBooleanResponse, handleBytesOrNullResponse, handleDoubleOrNullResponse, handleDoubleResponse, handleFunctionListResponse, handleFunctionListResponseBinary, handleFunctionStatsBinaryResponse, handleFunctionStatsBinaryResponse, handleFunctionStatsResponse, handleFunctionStatsResponse, handleGlideStringOrNullResponse, handleGlideStringResponse, handleLcsIdxResponse, handleLongOrNullResponse, handleLongResponse, handleMapOrNullResponse, handleMapResponse, handleObjectOrNullResponse, handleSetBinaryResponse, handleSetResponse, handleStringOrNullResponse, handleStringResponse, handleValkeyResponse, handleXReadResponse, handleXReadResponseBinary, hdel, hdel, hexists, hexists, hexpire, hexpire, hexpireat, hexpireat, hexpiretime, hexpiretime, hget, hget, hgetall, hgetall, hgetex, hgetex, hincrBy, hincrBy, hincrByFloat, hincrByFloat, hkeys, hkeys, hlen, hlen, hmget, hmget, hpersist, hpersist, hpexpire, hpexpire, hpexpireat, hpexpireat, hpexpiretime, hpexpiretime, hpttl, hpttl, hrandfield, hrandfield, hrandfieldWithCount, hrandfieldWithCount, hrandfieldWithCountWithValues, hrandfieldWithCountWithValues, hscan, hscan, hscan, hscan, hset, hset, hsetex, hsetex, hsetnx, hsetnx, hstrlen, hstrlen, httl, httl, hvals, hvals, incr, incr, incrBy, incrBy, incrByFloat, incrByFloat, invokeScript, invokeScript, invokeScript, isConnected, lcs, lcs, lcsIdx, lcsIdx, lcsIdx, lcsIdx, lcsIdxWithMatchLen, lcsIdxWithMatchLen, lcsIdxWithMatchLen, lcsIdxWithMatchLen, lcsLen, lcsLen, lindex, lindex, linsert, linsert, llen, llen, lmove, lmove, lmpop, lmpop, lmpop, lmpop, lpop, lpop, lpopCount, lpopCount, lpos, lpos, lpos, lpos, lposCount, lposCount, lposCount, lposCount, lpush, lpush, lpushx, lpushx, lrange, lrange, lrem, lrem, lset, lset, ltrim, ltrim, mget, mget, move, move, mset, msetBinary, msetnx, msetnxBinary, objectEncoding, objectEncoding, objectFreq, objectFreq, objectIdletime, objectIdletime, objectRefcount, objectRefcount, persist, persist, pexpire, pexpire, pexpire, pexpire, pexpireAt, pexpireAt, pexpireAt, pexpireAt, pexpiretime, pexpiretime, pfadd, pfadd, pfcount, pfcount, pfmerge, pfmerge, pttl, pttl, publish, publish, pubsubChannels, pubsubChannels, pubsubChannels, pubsubChannelsBinary, pubsubNumPat, pubsubNumSub, pubsubNumSub, refreshIamToken, rename, rename, renamenx, renamenx, restore, restore, rpop, rpop, rpopCount, rpopCount, rpush, rpush, rpushx, rpushx, sadd, sadd, scard, scard, scriptExists, scriptExists, scriptFlush, scriptFlush, scriptKill, scriptShow, scriptShow, sdiff, sdiff, sdiffstore, sdiffstore, set, set, set, set, setbit, setbit, setrange, setrange, sinter, sinter, sintercard, sintercard, sintercard, sintercard, sinterstore, sinterstore, sismember, sismember, smembers, smembers, smismember, smismember, smove, smove, sort, sort, sort, sort, sortReadOnly, sortReadOnly, sortReadOnly, sortReadOnly, sortStore, sortStore, sortStore, sortStore, spop, spop, spopCount, spopCount, srandmember, srandmember, srandmember, srandmember, srem, srem, sscan, sscan, sscan, sscan, strlen, strlen, sunion, sunion, sunionstore, sunionstore, touch, touch, tryGetPubSubMessage, ttl, ttl, type, type, unlink, unlink, updateConnectionPassword, updateConnectionPassword, wait, watch, watch, xack, xack, xadd, xadd, xadd, xadd, xadd, xadd, xadd, xadd, xautoclaim, xautoclaim, xautoclaim, xautoclaim, xautoclaimJustId, xautoclaimJustId, xautoclaimJustId, xautoclaimJustId, xclaim, xclaim, xclaim, xclaim, xclaimJustId, xclaimJustId, xclaimJustId, xclaimJustId, xdel, xdel, xgroupCreate, xgroupCreate, xgroupCreate, xgroupCreate, xgroupCreateConsumer, xgroupCreateConsumer, xgroupDelConsumer, xgroupDelConsumer, xgroupDestroy, xgroupDestroy, xgroupSetId, xgroupSetId, xgroupSetId, xgroupSetId, xinfoConsumers, xinfoConsumers, xinfoGroups, xinfoGroups, xinfoStream, xinfoStream, xinfoStreamFull, xinfoStreamFull, xinfoStreamFull, xinfoStreamFull, xlen, xlen, xpending, xpending, xpending, xpending, xpending, xpending, xrange, xrange, xrange, xrange, xread, xread, xreadBinary, xreadBinary, xreadgroup, xreadgroup, xreadgroup, xreadgroup, xrevrange, xrevrange, xrevrange, xrevrange, xtrim, xtrim, zadd, zadd, zadd, zadd, zadd, zadd, zadd, zadd, zaddIncr, zaddIncr, zaddIncr, zaddIncr, zcard, zcard, zcount, zcount, zdiff, zdiff, zdiffstore, zdiffstore, zdiffWithScores, zdiffWithScores, zincrby, zincrby, zinter, zinter, zintercard, zintercard, zintercard, zintercard, zinterstore, zinterstore, zinterstore, zinterstore, zinterWithScores, zinterWithScores, zinterWithScores, zinterWithScores, zlexcount, zlexcount, zmpop, zmpop, zmpop, zmpop, zmscore, zmscore, zpopmax, zpopmax, zpopmax, zpopmax, zpopmin, zpopmin, zpopmin, zpopmin, zrandmember, zrandmember, zrandmemberWithCount, zrandmemberWithCount, zrandmemberWithCountWithScores, zrandmemberWithCountWithScores, zrange, zrange, zrange, zrange, zrangestore, zrangestore, zrangestore, zrangestore, zrangeWithScores, zrangeWithScores, zrangeWithScores, zrangeWithScores, zrank, zrank, zrankWithScore, zrankWithScore, zrem, zrem, zremrangebylex, zremrangebylex, zremrangebyrank, zremrangebyrank, zremrangebyscore, zremrangebyscore, zrevrank, zrevrank, zrevrankWithScore, zrevrankWithScore, zscan, zscan, zscan, zscan, zscore, zscore, zunion, zunion, zunionstore, zunionstore, zunionstore, zunionstore, zunionWithScores, zunionWithScores, zunionWithScores, zunionWithScores
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface glide.api.commands.ScriptingAndFunctionsCommands
scriptExists, scriptExists, scriptFlush, scriptFlush, scriptKill
-
-
-
-
Constructor Detail
-
GlideClient
protected GlideClient(BaseClient.ClientBuilder builder)
Constructor using ClientParams from BaseClient.
-
-
Method Detail
-
createClient
public static java.util.concurrent.CompletableFuture<GlideClient> createClient(@NonNull @NonNull GlideClientConfiguration config)
Creates a newGlideClientinstance and establishes a connection to a standalone Valkey- Parameters:
config- The configuration options for the client, including server addresses, authentication credentials, TLS settings, database selection, reconnection strategy, and Pub/Sub subscriptions.- Returns:
- A Future that resolves to a connected
GlideClientinstance. - Example:
GlideClientConfiguration config = GlideClientConfiguration.builder() .address(node1address) .address(node2address) .useTLS(true) .readFrom(ReadFrom.PREFER_REPLICA) .credentials(credentialsConfiguration) .requestTimeout(2000) .clientName("GLIDE") .subscriptionConfiguration( StandaloneSubscriptionConfiguration.builder() .subscription(EXACT, "notifications") .subscription(EXACT, "news") .callback(callback) .build()) .inflightRequestsLimit(1000) .build(); GlideClient client = GlideClient.createClient(config).get();
-
customCommand
public java.util.concurrent.CompletableFuture<java.lang.Object> customCommand(@NonNull @NonNull java.lang.String[] args)Description copied from interface:GenericCommandsExecutes a single command, without checking inputs. Every part of the command, including subcommands, should be added as a separate value inargs.- Specified by:
customCommandin interfaceGenericCommands- Parameters:
args- Arguments for the custom command.- Returns:
- The returned value for the custom command.
- See Also:
- Valkey GLIDE Wiki for details on the restrictions and limitations of the custom command API.
-
customCommand
public java.util.concurrent.CompletableFuture<java.lang.Object> customCommand(@NonNull @NonNull GlideString[] args)Description copied from interface:GenericCommandsExecutes a single command, without checking inputs. Every part of the command, including subcommands, should be added as a separate value inargs.- Specified by:
customCommandin interfaceGenericCommands- Parameters:
args- Arguments for the custom command.- Returns:
- The returned value for the custom command.
- See Also:
- Valkey GLIDE Wiki for details on the restrictions and limitations of the custom command API.
-
exec
@Deprecated public java.util.concurrent.CompletableFuture<java.lang.Object[]> exec(@NonNull @NonNull Transaction transaction)Deprecated.- Specified by:
execin interfaceTransactionsCommands- Parameters:
transaction- ATransactionobject containing a list of commands to be executed.- Returns:
- A list of results corresponding to the execution of each command in the transaction.
- See Also:
TransactionsCommands.exec(Batch, boolean), valkey.io for details on Transactions.
-
exec
public java.util.concurrent.CompletableFuture<java.lang.Object[]> exec(@NonNull @NonNull Batch batch, boolean raiseOnError)Description copied from interface:TransactionsCommandsExecutes a batch by processing the queued commands.Notes:
- Atomic Batches - Transactions: If the transaction fails due to a
WATCHcommand,EXECwill returnnull.
- Specified by:
execin interfaceTransactionsCommands- Parameters:
batch- ABatchcontaining the commands to execute.raiseOnError- Determines how errors are handled within the batch response.When set to
true, the first encountered error in the batch will be raised as an exception of typeRequestExceptionafter all retries and reconnections have been executed.When set to
false, errors will be included as part of the batch response, allowing the caller to process both successful and failed commands together. In this case, error details will be provided as instances ofRequestException.- Returns:
- A
CompletableFutureresolving to an array of results, where each entry corresponds to a command’s execution result. - See Also:
- Valkey Transactions (Atomic Batches), Valkey Pipelines (Non-Atomic Batches)
- Atomic Batches - Transactions: If the transaction fails due to a
-
exec
public java.util.concurrent.CompletableFuture<java.lang.Object[]> exec(@NonNull @NonNull Batch batch, boolean raiseOnError, @NonNull @NonNull BatchOptions options)Description copied from interface:TransactionsCommandsExecutes a batch by processing the queued commands with additional options.Notes:
- Atomic Batches - Transactions: If the transaction fails due to a
WATCHcommand,EXECwill returnnull.
- Specified by:
execin interfaceTransactionsCommands- Parameters:
batch- ABatchcontaining the commands to execute.raiseOnError- Determines how errors are handled within the batch response.When set to
true, the first encountered error in the batch will be raised as an exception of typeRequestExceptionafter all retries and reconnections have been executed.When set to
false, errors will be included as part of the batch response, allowing the caller to process both successful and failed commands together. In this case, error details will be provided as instances ofRequestException.options- ABatchOptionsobject containing execution options.- Returns:
- A
CompletableFutureresolving to an array of results, where each entry corresponds to a command’s execution result. - See Also:
- Valkey Transactions (Atomic Batches), Valkey Pipelines (Non-Atomic Batches)
- Atomic Batches - Transactions: If the transaction fails due to a
-
ping
public java.util.concurrent.CompletableFuture<java.lang.String> ping()
Description copied from interface:ConnectionManagementCommandsPings the server.- Specified by:
pingin interfaceConnectionManagementCommands- Returns:
Stringwith"PONG".- See Also:
- valkey.io for details.
-
ping
public java.util.concurrent.CompletableFuture<java.lang.String> ping(@NonNull @NonNull java.lang.String message)Description copied from interface:ConnectionManagementCommandsPings the server.- Specified by:
pingin interfaceConnectionManagementCommands- Parameters:
message- The server will respond with a copy of the message.- Returns:
Stringwith a copy of the argumentmessage.- See Also:
- valkey.io for details.
-
ping
public java.util.concurrent.CompletableFuture<GlideString> ping(@NonNull @NonNull GlideString message)
Description copied from interface:ConnectionManagementCommandsPings the server.- Specified by:
pingin interfaceConnectionManagementCommands- Parameters:
message- The server will respond with a copy of the message.- Returns:
GlideStringwith a copy of the argumentmessage.- See Also:
- valkey.io for details.
-
info
public java.util.concurrent.CompletableFuture<java.lang.String> info()
Description copied from interface:ServerManagementCommandsGets information and statistics about the server using theInfoOptions.Section.DEFAULToption.- Specified by:
infoin interfaceServerManagementCommands- Returns:
- A
Stringwith the information for the default sections. - See Also:
- valkey.io for details.
-
info
public java.util.concurrent.CompletableFuture<java.lang.String> info(@NonNull @NonNull InfoOptions.Section[] sections)Description copied from interface:ServerManagementCommandsGet information and statistics about the server.
Starting from server version 7, command supports multiple section arguments.- Specified by:
infoin interfaceServerManagementCommands- Parameters:
sections- A list ofInfoOptions.Sectionvalues specifying which sections of information to retrieve. When no parameter is provided, theInfoOptions.Section.DEFAULToption is assumed.- Returns:
- A
Stringcontaining the information for the sections requested. - See Also:
- valkey.io for details.
-
select
public java.util.concurrent.CompletableFuture<java.lang.String> select(long index)
Description copied from interface:ConnectionManagementCommandsChanges the currently selected database.WARNING: This command is NOT RECOMMENDED for production use. Upon reconnection, the client will revert to the database_id specified in the client configuration (default: 0), NOT the database selected via this command.
RECOMMENDED APPROACH: Use the database_id parameter in client configuration instead:
RECOMMENDED EXAMPLE:
GlideClient client = GlideClient.createClient( GlideClientConfiguration.builder() .address(NodeAddress.builder().host("localhost").port(6379).build()) .databaseId(5) // Recommended: persists across reconnections .build() ).get();- Specified by:
selectin interfaceConnectionManagementCommands- Parameters:
index- The index of the database to select.- Returns:
- A simple
OKresponse. - See Also:
- valkey.io for details.
-
clientId
public java.util.concurrent.CompletableFuture<java.lang.Long> clientId()
Description copied from interface:ConnectionManagementCommandsGets the current connection id.- Specified by:
clientIdin interfaceConnectionManagementCommands- Returns:
- The id of the client.
- See Also:
- valkey.io for details.
-
clientGetName
public java.util.concurrent.CompletableFuture<java.lang.String> clientGetName()
Description copied from interface:ConnectionManagementCommandsGets the name of the current connection.- Specified by:
clientGetNamein interfaceConnectionManagementCommands- Returns:
- 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.
-
configRewrite
public java.util.concurrent.CompletableFuture<java.lang.String> configRewrite()
Description copied from interface:ServerManagementCommandsRewrites the configuration file with the current configuration.- Specified by:
configRewritein interfaceServerManagementCommands- Returns:
OKwhen the configuration was rewritten properly, otherwise an error is thrown.- See Also:
- valkey.io for details.
-
configResetStat
public java.util.concurrent.CompletableFuture<java.lang.String> configResetStat()
Description copied from interface:ServerManagementCommandsResets the statistics reported by the server using the INFO and LATENCY HISTOGRAM commands.- Specified by:
configResetStatin interfaceServerManagementCommands- Returns:
OKto confirm that the statistics were successfully reset.- See Also:
- valkey.io for details.
-
configGet
public java.util.concurrent.CompletableFuture<java.util.Map<java.lang.String,java.lang.String>> configGet(@NonNull @NonNull java.lang.String[] parameters)Description copied from interface:ServerManagementCommandsGet the values of configuration parameters.
Starting from server version 7, command supports multiple parameters.- Specified by:
configGetin interfaceServerManagementCommands- Parameters:
parameters- Anarrayof configuration parameter names to retrieve values for.- Returns:
- A
mapof values corresponding to the configuration parameters. - See Also:
- valkey.io for details.
-
configSet
public java.util.concurrent.CompletableFuture<java.lang.String> configSet(@NonNull @NonNull java.util.Map<java.lang.String,java.lang.String> parameters)Description copied from interface:ServerManagementCommandsSets configuration parameters to the specified values.
Starting from server version 7, command supports multiple parameters.- Specified by:
configSetin interfaceServerManagementCommands- Parameters:
parameters- Amapconsisting of configuration parameters and their respective values to set.- Returns:
OKif all configurations have been successfully set. Otherwise, raises an error.- See Also:
- valkey.io for details.
-
echo
public java.util.concurrent.CompletableFuture<java.lang.String> echo(@NonNull @NonNull java.lang.String message)Description copied from interface:ConnectionManagementCommandsEchoes the providedmessageback.- Specified by:
echoin interfaceConnectionManagementCommands- Parameters:
message- The message to be echoed back.- Returns:
- The provided
message. - See Also:
-
-
echo
public java.util.concurrent.CompletableFuture<GlideString> echo(@NonNull @NonNull GlideString message)
Description copied from interface:ConnectionManagementCommandsEchoes the providedmessageback.- Specified by:
echoin interfaceConnectionManagementCommands- Parameters:
message- The message to be echoed back.- Returns:
- The provided
message. - See Also:
-
-
time
public java.util.concurrent.CompletableFuture<java.lang.String[]> time()
Description copied from interface:ServerManagementCommandsReturns the server time.- Specified by:
timein interfaceServerManagementCommands- Returns:
- 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 java.util.concurrent.CompletableFuture<java.lang.Long> lastsave()
Description copied from interface:ServerManagementCommandsReturnsUNIX TIMEof the last DB save timestamp or startup timestamp if no save was made since then.- Specified by:
lastsavein interfaceServerManagementCommands- Returns:
UNIX TIMEof the last DB save executed with success.- See Also:
- valkey.io for details.
-
flushall
public java.util.concurrent.CompletableFuture<java.lang.String> flushall()
Description copied from interface:ServerManagementCommandsDeletes all the keys of all the existing databases. This command never fails.- Specified by:
flushallin interfaceServerManagementCommands- Returns:
OK.- See Also:
- valkey.io for details.
-
flushall
public java.util.concurrent.CompletableFuture<java.lang.String> flushall(@NonNull @NonNull FlushMode mode)Description copied from interface:ServerManagementCommandsDeletes all the keys of all the existing databases. This command never fails.- Specified by:
flushallin interfaceServerManagementCommands- Parameters:
mode- The flushing mode, could be eitherFlushMode.SYNCorFlushMode.ASYNC.- Returns:
OK.- See Also:
- valkey.io for details.
-
flushdb
public java.util.concurrent.CompletableFuture<java.lang.String> flushdb()
Description copied from interface:ServerManagementCommandsDeletes all the keys of the currently selected database. This command never fails.- Specified by:
flushdbin interfaceServerManagementCommands- Returns:
OK.- See Also:
- valkey.io for details.
-
flushdb
public java.util.concurrent.CompletableFuture<java.lang.String> flushdb(@NonNull @NonNull FlushMode mode)Description copied from interface:ServerManagementCommandsDeletes all the keys of the currently selected database. This command never fails.- Specified by:
flushdbin interfaceServerManagementCommands- Parameters:
mode- The flushing mode, could be eitherFlushMode.SYNCorFlushMode.ASYNC.- Returns:
OK.- See Also:
- valkey.io for details.
-
lolwut
public java.util.concurrent.CompletableFuture<java.lang.String> lolwut()
Description copied from interface:ServerManagementCommandsDisplays a piece of generative computer art and the Valkey version.- Specified by:
lolwutin interfaceServerManagementCommands- Returns:
- A piece of generative computer art along with the current Valkey version.
- See Also:
- valkey.io for details.
-
lolwut
public java.util.concurrent.CompletableFuture<java.lang.String> lolwut(int @NonNull [] parameters)
Description copied from interface:ServerManagementCommandsDisplays a piece of generative computer art and the Valkey version.- Specified by:
lolwutin interfaceServerManagementCommands- Parameters:
parameters- Additional set of arguments in order to change the output:- On Valkey version
5, those are length of the line, number of squares per row, and number of squares per column. - On Valkey version
6, those are number of columns and number of lines. - On other versions parameters are ignored.
- On Valkey version
- Returns:
- A piece of generative computer art along with the current Valkey version.
- See Also:
- valkey.io for details.
-
lolwut
public java.util.concurrent.CompletableFuture<java.lang.String> lolwut(int version)
Description copied from interface:ServerManagementCommandsDisplays a piece of generative computer art and the Valkey version.- Specified by:
lolwutin interfaceServerManagementCommands- Parameters:
version- Version of computer art to generate.- Returns:
- A piece of generative computer art along with the current Valkey version.
- See Also:
- valkey.io for details.
-
lolwut
public java.util.concurrent.CompletableFuture<java.lang.String> lolwut(int version, int @NonNull [] parameters)Description copied from interface:ServerManagementCommandsDisplays a piece of generative computer art and the Valkey version.- Specified by:
lolwutin interfaceServerManagementCommands- 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:
- A piece of generative computer art along with the current Valkey version.
- See Also:
- valkey.io for details.
-
dbsize
public java.util.concurrent.CompletableFuture<java.lang.Long> dbsize()
Description copied from interface:ServerManagementCommandsReturns the number of keys in the currently selected database.- Specified by:
dbsizein interfaceServerManagementCommands- Returns:
- The number of keys in the currently selected database.
- See Also:
- valkey.io for details.
-
functionLoad
public java.util.concurrent.CompletableFuture<java.lang.String> functionLoad(@NonNull @NonNull java.lang.String libraryCode, boolean replace)Description copied from interface:ScriptingAndFunctionsCommandsLoads a library to Valkey.- Specified by:
functionLoadin interfaceScriptingAndFunctionsCommands- 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:
- The library name that was loaded.
- See Also:
- valkey.io for details.
-
functionLoad
public java.util.concurrent.CompletableFuture<GlideString> functionLoad(@NonNull @NonNull GlideString libraryCode, boolean replace)
Description copied from interface:ScriptingAndFunctionsCommandsLoads a library to Valkey.- Specified by:
functionLoadin interfaceScriptingAndFunctionsCommands- 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:
- The library name that was loaded.
- See Also:
- valkey.io for details.
-
functionList
public java.util.concurrent.CompletableFuture<java.util.Map<java.lang.String,java.lang.Object>[]> functionList(boolean withCode)
Description copied from interface:ScriptingAndFunctionsCommandsReturns information about the functions and libraries.- Specified by:
functionListin interfaceScriptingAndFunctionsCommands- Parameters:
withCode- Specifies whether to request the library code from the server or not.- Returns:
- Info about all libraries and their functions.
- See Also:
- valkey.io for details.
-
functionListBinary
public java.util.concurrent.CompletableFuture<java.util.Map<GlideString,java.lang.Object>[]> functionListBinary(boolean withCode)
Description copied from interface:ScriptingAndFunctionsCommandsReturns information about the functions and libraries.- Specified by:
functionListBinaryin interfaceScriptingAndFunctionsCommands- Parameters:
withCode- Specifies whether to request the library code from the server or not.- Returns:
- Info about all libraries and their functions.
- See Also:
- valkey.io for details.
-
functionList
public java.util.concurrent.CompletableFuture<java.util.Map<java.lang.String,java.lang.Object>[]> functionList(@NonNull @NonNull java.lang.String libNamePattern, boolean withCode)Description copied from interface:ScriptingAndFunctionsCommandsReturns information about the functions and libraries.- Specified by:
functionListin interfaceScriptingAndFunctionsCommands- Parameters:
libNamePattern- A wildcard pattern for matching library names.withCode- Specifies whether to request the library code from the server or not.- Returns:
- Info about queried libraries and their functions.
- See Also:
- valkey.io for details.
-
functionListBinary
public java.util.concurrent.CompletableFuture<java.util.Map<GlideString,java.lang.Object>[]> functionListBinary(@NonNull @NonNull GlideString libNamePattern, boolean withCode)
Description copied from interface:ScriptingAndFunctionsCommandsReturns information about the functions and libraries.- Specified by:
functionListBinaryin interfaceScriptingAndFunctionsCommands- Parameters:
libNamePattern- A wildcard pattern for matching library names.withCode- Specifies whether to request the library code from the server or not.- Returns:
- Info about queried libraries and their functions.
- See Also:
- valkey.io for details.
-
functionFlush
public java.util.concurrent.CompletableFuture<java.lang.String> functionFlush()
Description copied from interface:ScriptingAndFunctionsCommandsDeletes all function libraries.- Specified by:
functionFlushin interfaceScriptingAndFunctionsCommands- Returns:
OK.- See Also:
- valkey.io for details.
-
functionFlush
public java.util.concurrent.CompletableFuture<java.lang.String> functionFlush(@NonNull @NonNull FlushMode mode)Description copied from interface:ScriptingAndFunctionsCommandsDeletes all function libraries.- Specified by:
functionFlushin interfaceScriptingAndFunctionsCommands- Parameters:
mode- The flushing mode, could be eitherFlushMode.SYNCorFlushMode.ASYNC.- Returns:
OK.- See Also:
- valkey.io for details.
-
functionDelete
public java.util.concurrent.CompletableFuture<java.lang.String> functionDelete(@NonNull @NonNull java.lang.String libName)Description copied from interface:ScriptingAndFunctionsCommandsDeletes a library and all its functions.- Specified by:
functionDeletein interfaceScriptingAndFunctionsCommands- Parameters:
libName- The library name to delete.- Returns:
OK.- See Also:
- valkey.io for details.
-
functionDelete
public java.util.concurrent.CompletableFuture<java.lang.String> functionDelete(@NonNull @NonNull GlideString libName)Description copied from interface:ScriptingAndFunctionsCommandsDeletes a library and all its functions.- Specified by:
functionDeletein interfaceScriptingAndFunctionsCommands- Parameters:
libName- The library name to delete.- Returns:
OK.- See Also:
- valkey.io for details.
-
functionDump
public java.util.concurrent.CompletableFuture<byte[]> functionDump()
Description copied from interface:ScriptingAndFunctionsCommandsReturns the serialized payload of all loaded libraries.- Specified by:
functionDumpin interfaceScriptingAndFunctionsCommands- Returns:
- The serialized payload of all loaded libraries.
- See Also:
- valkey.io for details.
-
functionRestore
public java.util.concurrent.CompletableFuture<java.lang.String> functionRestore(byte @NonNull [] payload)
Description copied from interface:ScriptingAndFunctionsCommandsRestores libraries from the serialized payload returned byScriptingAndFunctionsCommands.functionDump().- Specified by:
functionRestorein interfaceScriptingAndFunctionsCommands- Parameters:
payload- The serialized data fromScriptingAndFunctionsCommands.functionDump().- Returns:
OK.- See Also:
- valkey.io for details.
-
functionRestore
public java.util.concurrent.CompletableFuture<java.lang.String> functionRestore(byte @NonNull [] payload, @NonNull @NonNull FunctionRestorePolicy policy)Description copied from interface:ScriptingAndFunctionsCommandsRestores libraries from the serialized payload returned byScriptingAndFunctionsCommands.functionDump()..- Specified by:
functionRestorein interfaceScriptingAndFunctionsCommands- Parameters:
payload- The serialized data fromScriptingAndFunctionsCommands.functionDump().policy- A policy for handling existing libraries.- Returns:
OK.- See Also:
- valkey.io for details.
-
fcall
public java.util.concurrent.CompletableFuture<java.lang.Object> fcall(@NonNull @NonNull java.lang.String function)Description copied from interface:ScriptingAndFunctionsCommandsInvokes a previously loaded function.
This command is routed to primary nodes only.
To route to a replica please refer toScriptingAndFunctionsCommands.fcallReadOnly(java.lang.String).- Specified by:
fcallin interfaceScriptingAndFunctionsCommands- Parameters:
function- The function name.- Returns:
- The invoked function's return value.
- See Also:
- valkey.io for details.
-
fcall
public java.util.concurrent.CompletableFuture<java.lang.Object> fcall(@NonNull @NonNull GlideString function)Description copied from interface:ScriptingAndFunctionsCommandsInvokes a previously loaded function.
This command is routed to primary nodes only.
To route to a replica please refer toScriptingAndFunctionsCommands.fcallReadOnly(java.lang.String).- Specified by:
fcallin interfaceScriptingAndFunctionsCommands- Parameters:
function- The function name.- Returns:
- The invoked function's return value.
- See Also:
- valkey.io for details.
-
fcallReadOnly
public java.util.concurrent.CompletableFuture<java.lang.Object> fcallReadOnly(@NonNull @NonNull java.lang.String function)Description copied from interface:ScriptingAndFunctionsCommandsInvokes a previously loaded read-only function.
This command is routed depending on the client'sReadFromstrategy.- Specified by:
fcallReadOnlyin interfaceScriptingAndFunctionsCommands- Parameters:
function- The function name.- Returns:
- The invoked function's return value.
- See Also:
- valkey.io for details.
-
fcallReadOnly
public java.util.concurrent.CompletableFuture<java.lang.Object> fcallReadOnly(@NonNull @NonNull GlideString function)Description copied from interface:ScriptingAndFunctionsCommandsInvokes a previously loaded read-only function.
This command is routed depending on the client'sReadFromstrategy.- Specified by:
fcallReadOnlyin interfaceScriptingAndFunctionsCommands- Parameters:
function- The function name.- Returns:
- The invoked function's return value.
- See Also:
- valkey.io for details.
-
functionKill
public java.util.concurrent.CompletableFuture<java.lang.String> functionKill()
Description copied from interface:ScriptingAndFunctionsCommandsKills a function that is currently executing.
FUNCTION KILLterminates read-only functions only.FUNCTION KILLruns on all nodes of the server, including primary and replicas.- Specified by:
functionKillin interfaceScriptingAndFunctionsCommands- Returns:
OKif function is terminated. Otherwise, throws an error.- See Also:
- valkey.io for details.
-
functionStats
public java.util.concurrent.CompletableFuture<java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.Object>>>> functionStats()
Description copied from interface:ScriptingAndFunctionsCommandsReturns information about the function that's currently running and information about the available execution engines.
FUNCTION STATSruns on all nodes of the server, including primary and replicas. The response includes a mapping from node address to the command response for that node.- Specified by:
functionStatsin interfaceScriptingAndFunctionsCommands- Returns:
- A
Mapfrom node address to the command response for that node, where the command contains aMapwith two keys:running_scriptwith information about the running script.engineswith information about available engines and their stats.
- See Also:
- valkey.io for details.
-
functionStatsBinary
public java.util.concurrent.CompletableFuture<java.util.Map<java.lang.String,java.util.Map<GlideString,java.util.Map<GlideString,java.lang.Object>>>> functionStatsBinary()
Description copied from interface:ScriptingAndFunctionsCommandsReturns information about the function that's currently running and information about the available execution engines.
FUNCTION STATSruns on all nodes of the server, including primary and replicas. The response includes a mapping from node address to the command response for that node.- Specified by:
functionStatsBinaryin interfaceScriptingAndFunctionsCommands- Returns:
- A
Mapfrom node address to the command response for that node, where the command contains aMapwith two keys:running_scriptwith information about the running script.engineswith information about available engines and their stats.
- See Also:
- valkey.io for details.
-
unwatch
public java.util.concurrent.CompletableFuture<java.lang.String> unwatch()
Description copied from interface:TransactionsCommandsFlushes all the previously watched keys for a transaction. Executing a transaction will automatically flush all previously watched keys.- Specified by:
unwatchin interfaceTransactionsCommands- Returns:
OK.- See Also:
- valkey.io for details.
-
randomKey
public java.util.concurrent.CompletableFuture<java.lang.String> randomKey()
Description copied from interface:GenericCommandsReturns a random key from currently selected database.- Specified by:
randomKeyin interfaceGenericCommands- Returns:
- A random
keyfrom the database. - See Also:
- valkey.io for details.
-
randomKeyBinary
public java.util.concurrent.CompletableFuture<GlideString> randomKeyBinary()
Description copied from interface:GenericCommandsReturns a random key from currently selected database.- Specified by:
randomKeyBinaryin interfaceGenericCommands- Returns:
- A random
keyfrom the database. - See Also:
- valkey.io for details.
-
scan
public java.util.concurrent.CompletableFuture<java.lang.Object[]> scan(@NonNull @NonNull java.lang.String cursor)Description copied from interface:GenericCommandsIterates incrementally over a database for matching keys.- Specified by:
scanin interfaceGenericCommands- Parameters:
cursor- The cursor that points to the next iteration of results. A value of"0"indicates the start of the search.- Returns:
- An
ArrayofObjects. The first element is always thecursorfor the next iteration of results."0"will be thecursorreturned on the last iteration of the scan.
The second element is always anArrayof matched keys from the database. - See Also:
- valkey.io for details.
-
scan
public java.util.concurrent.CompletableFuture<java.lang.Object[]> scan(@NonNull @NonNull GlideString cursor)Description copied from interface:GenericCommandsIterates incrementally over a database for matching keys.- Specified by:
scanin interfaceGenericCommands- Parameters:
cursor- The cursor that points to the next iteration of results. A value ofgs("0")indicates the start of the search.- Returns:
- An
ArrayofObjects. The first element is always thecursorfor the next iteration of results.gs("0")will be thecursorreturned on the last iteration of the scan.
The second element is always anArrayof matched keys from the database. - See Also:
- valkey.io for details.
-
scan
public java.util.concurrent.CompletableFuture<java.lang.Object[]> scan(@NonNull @NonNull java.lang.String cursor, @NonNull @NonNull ScanOptions options)Description copied from interface:GenericCommandsIterates incrementally over a database for matching keys.- Specified by:
scanin interfaceGenericCommands- Parameters:
cursor- The cursor that points to the next iteration of results. A value of"0"indicates the start of the search.options- TheScanOptions.- Returns:
- An
ArrayofObjects. The first element is always thecursorfor the next iteration of results."0"will be thecursorreturned on the last iteration of the scan.
The second element is always anArrayof matched keys from the database. - See Also:
- valkey.io for details.
-
scan
public java.util.concurrent.CompletableFuture<java.lang.Object[]> scan(@NonNull @NonNull GlideString cursor, @NonNull @NonNull ScanOptions options)Description copied from interface:GenericCommandsIterates incrementally over a database for matching keys.- Specified by:
scanin interfaceGenericCommands- Parameters:
cursor- The cursor that points to the next iteration of results. A value ofgs("0")indicates the start of the search.options- TheScanOptions.- Returns:
- An
ArrayofObjects. The first element is always thecursorfor the next iteration of results.gs("0")will be thecursorreturned on the last iteration of the scan.
The second element is always anArrayof matched keys from the database. - See Also:
- valkey.io for details.
-
-
-
-