RedisClient class abstract base

A Redis client for one isolate, for one server (RedisNodeClient: a standalone server or Sentinel's master) or a Redis Cluster (RedisClusterClient), as its config says.

Commands share one connection per server (replies are matched in order, so concurrent commands pipeline), opened on first use and again after it drops. Blocking commands and Pub/Sub take connections of their own (dedicated, subscribe).

Implementers

Constructors

RedisClient(RedisConnectionConfig config)
factory

Properties

config → RedisConnectionConfig
final
hashCode → int
The hash code for this object.
no setterinherited
isClosed → bool
Whether close was called.
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
stats → Map<String, Object?>
What this client did: connections opened, commands waiting for replies, Sentinel or Cluster lookups and redirections.
no setter

Methods

close() → Future<void>
Closes every connection of this client.
command(List<Object?> args, {Duration? timeout}) → Future<Object?>
Sends one command (['SET', 'key', 'value']) and returns its reply: a String, int, List, null, ... An error reply throws RedisCommandException; a dropped connection or a timeout, RedisConnectionException.
dedicated({String? key, void onMessage(List<Object?> message)?}) → Future<RedisConnection>
A connection of its own, for blocking commands (BLPOP) on key (whose server it reaches in a cluster), its pushes to onMessage; closed with the client.
del(List<String> keys) → Future<int>
eval(RedisScript script, {List<String> keys = const [], List<Object?> args = const []}) → Future<Object?>
Runs script in one round trip: by its SHA1, or by its source the first time this server sees it.
get(String key) → Future<String?>
masterClients() → Future<List<RedisNodeClient>>
A client of each master: this one on a single server, one per master of a cluster.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
pipeline(List<List<Object?>> commands) → Future<List<Object?>>
Sends commands together and returns their replies in order, an error reply as a RedisCommandException in its place.
publish(String channel, String message, {bool sharded = false}) → Future<int>
PUBLISH (SPUBLISH when sharded): how many subscribers received message.
scan({String? match, int count = 500}) → Stream<String>
The keys matching match (a SCAN glob), on every master.
set(String key, Object value, {Duration? ttl, bool onlyIfAbsent = false}) → Future<bool>
SET; ttl sets PX, onlyIfAbsent NX (then false when the key existed).
slot(String key) → int?
The hash slot of key in a cluster; null on one server, where every key is together.
subscribe(List<String> channels, {bool pattern = false, bool sharded = false}) → RedisSubscription
Messages published on channels (or matching them, with pattern), on a connection of its own that subscribes again after it drops.
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited