RedisStore class

Implements cache storage and locking using a Redis server.

Values are encoded with a small type prefix so strings, numbers, booleans, null, and JSON-compatible objects can share one Redis keyspace. The store connects lazily on first use and reconnects after a command failure.

Inheritance
Implemented types

Constructors

RedisStore(String host, int port, {String? password, int? db, RedisConnection? connection, Future sendOverride(List)?})
Creates a Redis store connected to host and port.

Properties

db → int?
Optional Redis database number.
final
hashCode → int
The hash code for this object.
no setterinherited
host → String
Redis hostname or address.
final
password → String?
Optional Redis password.
final
port → int
Redis TCP port.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

acquireLock(String name, String owner, int seconds) → Future<bool>
Acquires name for owner with a lifetime of seconds.
add(String key, dynamic value, int seconds) → Future<bool>
Atomically stores value only when key is absent.
override
decrement(String key, [dynamic value = 1]) → Future
Decrements the integer value at key while preserving its Redis TTL.
override
flush() → Future<bool>
Flushes the selected Redis database.
override
forceReleaseLock(String name) → void
Removes name without checking its owner.
forever(String key, dynamic value) → Future<bool>
Stores value without an expiration.
override
forget(String key) → Future<bool>
Deletes key and reports whether Redis removed an entry.
override
get(String key) → Future
Returns and decodes the value stored at key.
override
getAllKeys() → Future<List<String>>
Scans Redis for keys in the selected database.
override
getPrefix() → String
Returns the empty key prefix used by this store.
override
increment(String key, [dynamic value = 1]) → Future
Increments the integer value at key while preserving its Redis TTL.
override
lock(String name, [int seconds = 0, String? owner]) → Future<Lock>
Creates a Redis-backed lock handle for name.
override
lockOwner(String name) → Future<String?>
Returns the current owner of name, if it is locked.
many(List<String> keys) → Future<Map<String, dynamic>>
Returns decoded values for keys, using null for misses.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
put(String key, dynamic value, int seconds) → Future<bool>
Encodes and stores value at key, optionally expiring it after seconds.
override
putMany(Map<String, dynamic> values, int seconds) → Future<bool>
Writes each entry in values with the same TTL.
override
releaseLock(String name, String owner) → Future<bool>
Releases name only when it is owned by owner.
restoreLock(String name, String owner) → Future<Lock>
Restores a Redis lock handle for an existing owner.
override
tags(List<String> names) → TaggedCache
Creates a TaggedCache instance with the specified tags.
inherited
toString() → String
A string representation of this object.
inherited

Operators

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