TimedMap<K, V> class

A Map where the keys have a put time (DateTime) and also can expire.

Implemented types
Available extensions

Constructors

TimedMap(Duration keyTimeout, [Map<K, V>? map, bool? keyTimeoutChecker(TimedMap timedMap, Object? key, Duration elapsedTime, Duration keyTimeout)?])

Properties

entries → Iterable<MapEntry<K, V>>
Returns the entries of this instance, without check keyTimeout. See checkAllEntries.
no setteroverride
hashCode → int
The hash code for this object.
no setterinherited
isEmpty → bool
Whether there is no key/value pair in the map.
no setteroverride
isNotEmpty → bool
Whether there is at least one key/value pair in the map.
no setteroverride
keys → Iterable<K>
Returns the keys of this instance, without check keyTimeout. See checkAllEntries.
no setteroverride
keyTimeout → Duration
The key timeout. When a key is put, it expires after the timeout Duration.
final
keyTimeoutChecker → bool? Function(TimedMap timedMap, Object? key, Duration elapsedTime, Duration keyTimeout)?
final
length → int
The number of key/value pairs in the map.
no setteroverride
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
values → Iterable<V>
Returns the values of this instance, without check keyTimeout. See checkAllEntries.
no setteroverride

Methods

addAll(Map<K, V> other) → void
Adds all key/value pairs of other to this map.
override
addEntries(Iterable<MapEntry<K, V>> newEntries) → void
Adds all key/value pairs of newEntries to this map.
override
bestOrder() → Map<K, CreateTableSQL>

Available on Map<K, CreateTableSQL>, provided by the SQLBuilderMapExtension extension

cast<RK, RV>() → Map<RK, RV>
Provides a view of this map as having RK keys and RV instances, if necessary.
override
checkAllEntries({DateTime? now, Duration? keyTimeout}) → int
Checks all the entries of this instance.
checkCachedEntry(K key) → void

Available on Map<K, V>, provided by the MapAsCacheExtension extension

checkCacheLimit(int? cacheLimit) → int

Available on Map<K, V>, provided by the MapAsCacheExtension extension

Checks if this Map.length is bigger than cacheLimit and removes elements to not exceed the cacheLimit.
checkEntry(Object? key, {DateTime? now, Duration? keyTimeout}) → bool
Check the key entry timeout. Returns true if the key expired.
clear() → void
Removes all entries from the map.
override
containsKey(Object? key) → bool
Whether this map contains the given key.
override
containsValue(Object? value) → bool
Whether this map contains the given value.
override
entriesChecked({DateTime? now, Duration? keyTimeout}) → List<MapEntry<K, V>>
Returns the entries of this instance checking keyTimeout. See checkAllEntries.
equivalentCaches(C context) → Iterable<M>

Available on Map<C, Map<K, V>>, provided by the MapOfCachesExtension extension

forEach(void action(K key, V value)) → void
Applies action to each key/value pair of the map.
override
get(K key, {V? defaultValue, bool ignoreCase = false}) → V?

Available on Map<K, V>, provided by the MapGetterExtension extension

Gets a key value.
getAs<T>(K key, {T? defaultValue, bool ignoreCase = false}) → T?

Available on Map<K, V>, provided by the MapGetterExtension extension

Gets a key value parsing to T type.
getAsBool(K key, {bool? defaultValue, bool ignoreCase = false}) → bool?

Available on Map<K, V>, provided by the MapGetterExtension extension

Gets a key value parsing as bool.
getAsDouble(K key, {double? defaultValue, bool ignoreCase = false}) → double?

Available on Map<K, V>, provided by the MapGetterExtension extension

Gets a key value parsing as double.
getAsInt(K key, {int? defaultValue, bool ignoreCase = false}) → int?

Available on Map<K, V>, provided by the MapGetterExtension extension

Gets a key value parsing as int.
getAsList<E>(K key, {List<E>? def, TypeElementParser<E>? elementParser, List<E>? defaultValue, bool ignoreCase = false}) → List<E>?

Available on Map<K, V>, provided by the MapGetterExtension extension

Gets a key value parsing as List.
getAsMap(K key, {Map<K, V>? def, TypeElementParser<K>? keyParser, TypeElementParser<V>? valueParser, Map<K, V>? defaultValue, bool ignoreCase = false}) → Map<K, V>?

Available on Map<K, V>, provided by the MapGetterExtension extension

Gets a key value parsing as Map.
getAsNum(K key, {num? defaultValue, bool ignoreCase = false}) → num?

Available on Map<K, V>, provided by the MapGetterExtension extension

Gets a key value parsing to num type.
getAsSet<E>(K key, {Set<E>? def, TypeElementParser<E>? elementParser, Set<E>? defaultValue, bool ignoreCase = false}) → Set<E>?

Available on Map<K, V>, provided by the MapGetterExtension extension

Gets a key value parsing as Set.
getAsString(K key, {String? defaultValue, bool ignoreCase = false}) → String?

Available on Map<K, V>, provided by the MapGetterExtension extension

Gets a key value parsing as String.
getCache(C context, M cacheInstantiator()) → M

Available on Map<C, Map<K, V>>, provided by the MapOfCachesExtension extension

getCached(K key, V computer(), {int? cacheLimit}) → V

Available on Map<K, V>, provided by the MapAsCacheExtension extension

Returns key value or computes it and caches it. See checkCachedEntry, checkCacheLimit and getCachedAsync.
getCachedAsync(K key, FutureOr<V> computer(), {int? cacheLimit}) → FutureOr<V>

Available on Map<K, V>, provided by the MapAsCacheExtension extension

Same as getCached but accepts a computer that returns a Future. See checkCachedEntry, checkCacheLimit and getCachedAsync.
getCachedAsyncNullable(K key, FutureOr<V?> computer(), {int? cacheLimit}) → FutureOr<V?>

Available on Map<K, V>, provided by the MapAsCacheExtension extension

getCachedNullable(K key, V? computer(), {int? cacheLimit}) → V?

Available on Map<K, V>, provided by the MapAsCacheExtension extension

getChecked(K key, {DateTime? now, Duration? keyTimeout}) → V?
Returns a key checking keyTimeout.
getElapsedTime(Object? key, {DateTime? now}) → Duration?
Returns the elapsed time of key, since the put.
getFirstValue(K key, {bool ignoreCase = false}) → String?

Available on Map<K, Object>, provided by the MapMultiValueExtension extension

Returns the first value for key, if present.
getIfCached(K key, {int? cacheLimit}) → V?

Available on Map<K, V>, provided by the MapAsCacheExtension extension

Returns key value, checking if it's still valid. See checkCachedEntry and checkCacheLimit.
getIfCached(K key, C context, M cacheInstantiator()) → V?

Available on Map<C, Map<K, V>>, provided by the MapOfCachesExtension extension

getIgnoreCase(K key, {V? defaultValue}) → V?

Available on Map<K, V>, provided by the MapGetterExtension extension

Gets a key value ignoring case.
getMultiCached(K key, C context, M cacheInstantiator(), V computer()) → V

Available on Map<C, Map<K, V>>, provided by the MapOfCachesExtension extension

getMultiCachedAsync(K key, C context, M cacheInstantiator(), FutureOr<V> computer()) → FutureOr<V>

Available on Map<C, Map<K, V>>, provided by the MapOfCachesExtension extension

getMultiCachedAsyncNullable(K key, C context, M cacheInstantiator(), FutureOr<V?> computer()) → FutureOr<V?>

Available on Map<C, Map<K, V>>, provided by the MapOfCachesExtension extension

getMultiCachedNullable(K key, C context, M cacheInstantiator(), V? computer()) → V?

Available on Map<C, Map<K, V>>, provided by the MapOfCachesExtension extension

getMultiKeyAsBool(List<K> keys, {bool? defaultValue, bool ignoreCase = false}) → bool?

Available on Map<K, V>, provided by the MapGetterExtension extension

Gets the value of the first matching keys, parsing as bool.
getMultiKeyAsDouble(List<K> keys, {double? defaultValue, bool ignoreCase = false}) → double?

Available on Map<K, V>, provided by the MapGetterExtension extension

Gets the value of the first matching keys, parsing as double.
getMultiKeyAsInt(List<K> keys, {int? defaultValue, bool ignoreCase = false}) → int?

Available on Map<K, V>, provided by the MapGetterExtension extension

Gets the value of the first matching keys, parsing as int.
getMultiKeyAsNum(List<K> keys, {num? defaultValue, bool ignoreCase = false}) → num?

Available on Map<K, V>, provided by the MapGetterExtension extension

Gets the value of the first matching keys, parsing as num.
getMultiKeyAsString(List<K> keys, {String? defaultValue, bool ignoreCase = false}) → String?

Available on Map<K, V>, provided by the MapGetterExtension extension

Gets the value of the first matching keys, parsing as num.
getMultiKeyParsed<T>(List<K> keys, TypeElementParser<T>? parser, {T? defaultValue, bool ignoreCase = false}) → T?

Available on Map<K, V>, provided by the MapGetterExtension extension

Same as getParsed but accepts multiple keys.
getMultiValue(K key, {bool ignoreCase = false}) → List<String>?

Available on Map<K, Object>, provided by the MapMultiValueExtension extension

Returns the first values for key.
getParsed<T>(K key, TypeElementParser<T>? parser, {T? defaultValue, bool ignoreCase = false}) → T?

Available on Map<K, V>, provided by the MapGetterExtension extension

Gets a key value parsing with parser.
getTime(Object? key) → DateTime?
Returns the time (DateTime) of a key.
isEntryExpired(Object? key, {DateTime? now, Duration? keyTimeout}) → bool
Returns true if the key entry is expired (reached the timeout).
isEquivalentContext(C context1, C context2) → bool

Available on Map<C, Map<K, V>>, provided by the MapOfCachesExtension extension

keysChecked({DateTime? now, Duration? keyTimeout}) → List<K>
Returns the keys of this instance checking keyTimeout. See checkAllEntries.
map<K2, V2>(MapEntry<K2, V2> convert(K key, V value)) → TimedMap<K2, V2>
Returns a new map where all entries of this map are transformed by the given convert function.
override
matchKey(K key) → K?

Available on Map<K, V>, provided by the MapGetterExtension extension

Returns the existing key that matches key.
matchKeyIgnoreCase(K key) → K?

Available on Map<K, V>, provided by the MapGetterExtension extension

Returns the existing key that matches key as case-insensitive.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
populateMultiCache(K key, C context, M cacheInstantiator(), V value) → void

Available on Map<C, Map<K, V>>, provided by the MapOfCachesExtension extension

put(K key, V value, {DateTime? now}) → void
Sets a key value.
putIfAbsent(K key, V ifAbsent()) → V
Look up the value of key, or add a new entry if it isn't there.
override
putIfAbsentChecked(K key, V ifAbsent(), {DateTime? now, Duration? keyTimeout}) → V
Same as putIfAbsent, but calls checkEntry first.
putIfAbsentCheckedAsync(K key, FutureOr<V> ifAbsent(), {DateTime? now, Duration? keyTimeout}) → FutureOr<V>
Same as putIfAbsentChecked, but accepts an async function for ifAbsent.
remove(Object? key) → V?
Removes key and its associated value, if present, from the map.
override
removeWhere(bool test(K key, V value)) → void
Removes keys where test returns true. See removeWhereTimed.
override
removeWhereTimed(bool test(K key, V value, DateTime time)) → void
Removes keys where test returns true. See removeWhere.
setMultiValue(K key, String value, {bool ignoreCase = false}) → void

Available on Map<K, Object>, provided by the MapMultiValueExtension extension

Sets the value for key. If the value already exists, ensures that is a List<String>.
toHierarchicalOrder() → Map<K, CreateTableSQL>

Available on Map<K, CreateTableSQL>, provided by the SQLBuilderMapExtension extension

toString() → String
A string representation of this object.
override
update(K key, V update(V value), {V ifAbsent()?}) → V
Updates the value for the provided key.
override
updateAll(V update(K key, V value)) → void
Updates all values.
override
updateAllTimed(V update(K key, V value, DateTime time)) → void
Same as updateAll, but with an extra parameter time in function update.
updateTimed(K key, V update(V value), {V ifAbsent()?, DateTime? now, Duration? keyTimeout}) → V
Same as update, but calls checkEntry first.
valuesChecked({DateTime? now, Duration? keyTimeout}) → List<V>
Returns the values of this instance checking keyTimeout. See checkAllEntries.

Operators

operator ==(Object other) → bool
The equality operator.
inherited
operator [](Object? key) → V?
Returns a key without check keyTimeout. See getChecked.
override
operator []=(K key, V value) → void
Sets a key value. See put.
override