ValkeyClient class
The main client implementation for communicating with a Valkey server.
- Implemented types
Constructors
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- isConnected → bool
-
Returns true if the client has an active socket connection.
no setter
- isStateful → bool
-
Returns true if the client is in a stateful mode that makes it
unsuitable for reuse without a reset (e.g., Pub/Sub, Transaction).
no setter
-
onConnected
→ Future<
void> -
A Future that completes once the connection and authentication are successful.
no setteroverride
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
close(
) → Future< void> -
Closes the connection to the server.
override
-
clusterSlots(
) → Future< List< ClusterSlotRange> > -
Fetches the cluster topology information from the server.
override
-
connect(
{String? host, int? port, String? username, String? password}) → Future< void> -
Connects to the Valkey server.
override
-
decr(
String key) → Future< int> -
Decrements the number stored at
keyby one.override -
decrBy(
String key, int amount) → Future< int> -
Decrements the number stored at
keybyamount.override -
del(
String key) → Future< int> -
Deletes the specified
key.override -
discard(
) → Future< String> -
Discards all commands queued after
multi().override -
echo(
String message) → Future< String> -
Echoes the given
messageback from the server.override -
exec(
) → Future< List?> -
Executes all commands queued after
multi().override -
execute(
List< String> command) → Future -
Executes a raw command. (This will be our main internal method)
Returns a Future that completes with the server's response.
Handle SSUBSCRIBE/SUNSUBSCRIBE futures
override
-
exists(
String key) → Future< int> -
Checks if
keyexists.override -
expire(
String key, int seconds) → Future< int> -
Sets a timeout on
keyin seconds.override -
get(
String key) → Future< String?> -
Gets the value of
key.override -
hget(
String key, String field) → Future< String?> -
Gets the value of
fieldin the hash stored atkey.override -
hgetall(
String key) → Future< Map< String, String> > -
Gets all fields and values of the hash stored at
key.override -
hset(
String key, String field, String value) → Future< int> -
Sets
fieldin the hash stored atkeytovalue.override -
incr(
String key) → Future< int> -
Increments the number stored at
keyby one.override -
incrBy(
String key, int amount) → Future< int> -
Increments the number stored at
keybyamount.override -
lpop(
String key) → Future< String?> -
Removes and returns the first element of the list stored at
key.override -
lpush(
String key, String value) → Future< int> -
Prepends
valueto the list stored atkey.override -
lrange(
String key, int start, int stop) → Future< List< String?> > -
Returns the specified elements of the list stored at
key.override -
mget(
List< String> keys) → Future<List< String?> > -
Gets the values of all specified
keys.override -
multi(
) → Future< String> -
Marks the start of a transaction block.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
ping(
[String? message]) → Future< String> -
PINGs the server.
override
-
psubscribe(
List< String> patterns) → Subscription -
Subscribes the client to the given
patterns(e.g., "log:*").override -
publish(
String channel, String message) → Future< int> -
Posts a
messageto the givenchannel.override -
pubsubChannels(
[String? pattern]) → Future< List< String?> > -
Lists the currently active channels.
override
-
pubsubNumPat(
) → Future< int> -
Returns the number of subscriptions to patterns.
override
-
pubsubNumSub(
List< String> channels) → Future<Map< String, int> > -
Returns the number of subscribers for the specified
channels.override -
punsubscribe(
[List< String> patterns = const []]) → Future<void> -
Unsubscribes the client from the given
patterns, or all patterns if none are given.override -
rpop(
String key) → Future< String?> -
Removes and returns the last element of the list stored at
key.override -
rpush(
String key, String value) → Future< int> -
Appends
valueto the list stored atkey.override -
sadd(
String key, String member) → Future< int> -
Adds
memberto the set stored atkey.override -
set(
String key, String value) → Future< String> -
Sets
keytovalue.override -
smembers(
String key) → Future< List< String?> > -
Returns all members of the set stored at
key.override -
spublish(
String channel, String message) → Future< int> -
Posts a
messageto the givenchannelusing Sharded Pub/Sub. Returns the number of clients that received the message. Note: In Cluster mode, this command is routed to the specific node that owns the slot forchannel.override -
srem(
String key, String member) → Future< int> -
Removes
memberfrom the set stored atkey.override -
ssubscribe(
List< String> channels) → Subscription -
Subscribes the client to the specified
channelsusing Sharded Pub/Sub.override -
subscribe(
List< String> channels) → Subscription -
Subscribes the client to the specified
channels.override -
sunsubscribe(
[List< String> channels = const []]) → Future<void> -
Unsubscribes from the given
channelsusing Sharded Pub/Sub.override -
toString(
) → String -
A string representation of this object.
inherited
-
ttl(
String key) → Future< int> -
Gets the remaining time to live of a
keyin seconds.override -
unsubscribe(
[List< String> channels = const []]) → Future<void> -
Unsubscribes the client from the given
channels, or all channels if none are given.override -
zadd(
String key, double score, String member) → Future< int> -
Adds
memberwith the specifiedscoreto the sorted set stored atkey.override -
zrange(
String key, int start, int stop) → Future< List< String?> > -
Returns the specified range of members in the sorted set stored at
key, ordered from lowest to highest score.override -
zrem(
String key, String member) → Future< int> -
Removes
memberfrom the sorted set stored atkey.override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
setLogLevel(
ValkeyLogLevel level) → void - Sets the logging level for all ValkeyClient instances.