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
valueonly whenkeyis missing; returns whether it did. -
decrement(
String key, [int by = 1]) → Future< int> -
Subtracts
byfrom the integer underkeyand 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
valueunderkeywith 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, orfallbackwhen missing. -
has(
String key) → Future< bool> -
Whether
keyholds a value. -
increment(
String key, [int by = 1]) → Future< int> -
Adds
byto the integer underkeyand 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
keyholds 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
valueunderkey, forttlor 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')). -
The default store with its entries tagged
names(Laravel'sCache::tags). -
touch(
String key, Duration ttl) → Future< bool> -
Gives
keya newttl; returns whether it existed.