TimeToLiveCachedValue<CacheContentType> class

A CachedValue that is invalidated some time after a refresh.

It keeps an internal Timer that is restarted very time the cache is refreshed.

After that time, isValid will be false and any access to value will trigger refresh and the timer will be restarted.

Besides dependency change, this cache can also be manually updated on marked as invalid via refresh and invalidate.

The duration of the timer is equal to lifeTime.

Do not wrap a TTL cache on another, otherwise an assertion will be thrown.

It can be created via CachedValue.withTimeToLive

Inheritance
Available Extensions

Properties

child CachedValue<CacheContentType>
A CachedValue in which this cache wraps.
finalinherited
hashCode int
The hash code for this object.
no setterinherited
isValid bool
Check the current state of the cache.
no setteroverride
lifeTime Duration
The amount of time that will take to the cache to be considered invalid after a refresh.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
value → CacheContentType
Access the current cache value.
no setteroverride

Methods

invalidate() → void
Marks the cache as invalid.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
refresh() → CacheContentType
Calls refresh on its child and restarts the internal Timer.
override
toString() String
A string representation of this object.
inherited

Operators

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