Cache class abstract final

Cache access (Cache::get, Cache::remember, Cache::lock).

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 Properties

manager → CacheManager
The cache manager of the current container.
no setter

Static Methods

add(String key, Object? value, {Duration? ttl}) → Future<bool>
Stores value only when key is missing; returns whether it did.
decrement(String key, [int by = 1]) → Future<int>
Subtracts by from the integer under key and returns the new value.
flexible<T>(String key, (Duration, Duration) window, FutureOr<T> compute()) → Future<T>
Stale-while-revalidate: fresh for the first duration, then served stale while it refreshes in the background, until the second.
flush() → Future<void>
Removes every value of the default store.
forever(String key, Object? value) → Future<void>
Stores value under key with no expiry.
forget(String key) → Future<bool>
Removes key; returns whether it existed.
get<T>(String key, [T? fallback]) → Future<T?>
The value of key, or fallback when missing.
has(String key) → Future<bool>
Whether key holds a value.
increment(String key, [int by = 1]) → Future<int>
Adds by to the integer under key and returns the new value.
lock(String name, {Duration ttl = const Duration(seconds: 10), String? owner}) → Lock
An atomic lock named by the key, held for the given duration: await Cache.lock('report', 10.seconds).get(() => ...).
many(List<String> keys) → Future<Map<String, Object?>>
The values of keys, null for the missing ones.
missing(String key) → Future<bool>
Whether key holds nothing.
pull<T>(String key, [T? fallback]) → Future<T?>
The value of key, removed from the cache.
put(String key, Object? value, {Duration? ttl}) → Future<void>
Stores value under key, for ttl or forever.
putMany(Map<String, Object?> values, {Duration? ttl}) → Future<void>
Stores every entry of values.
remember<T>(String key, Duration? ttl, FutureOr<T> compute()) → Future<T>
The value of key, or the callback's result stored for the given ttl: Cache.remember('stats', 10.minutes, () => compute()).
rememberForever<T>(String key, FutureOr<T> compute()) → Future<T>
The value of key, or the callback's result stored forever.
store([String? name]) → CacheRepository
The default store, or name (Cache::store('file')).
tags(List<String> names) → CacheRepository
The default store with its entries tagged names (Laravel's Cache::tags).
touch(String key, Duration ttl) → Future<bool>
Gives key a new ttl; returns whether it existed.