Cache class

The global Cache manager.

await Cache.put('key', 'value', ttl: Duration(minutes: 5));
final val = await Cache.get<String>('key');

Constructors

Cache()
Internal constructor for Cache.

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

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

Static Methods

decrement(String key, [int value = 1]) Future<int>
Decrements the value of an item.
flush() Future<void>
Clears the entire cache.
forget(String key) Future<void>
Removes an item.
get<T>(String key) Future<T?>
Retrieves an item from the cache.
has(String key) Future<bool>
Checks if an item exists.
increment(String key, [int value = 1]) Future<int>
Increments the value of an item.
put(String key, dynamic value, {Duration? ttl}) Future<void>
Stores an item in the cache.
remember<T>(String key, Duration ttl, FutureOr<T> callback()) Future<T>
Retrieves an item, or stores the result of the callback if it doesn't exist.
use(CacheDriver driver) → void
Sets the global cache driver.