UserCachette<K, V extends Object, U extends Object> class

A Cachette that allows you to establish user type bounds.

Inheritance

Constructors

UserCachette(int size, {EvictionPolicy evictionPolicy = EvictionPolicy.leastRecentlyUsed, void onEvict(CacheEntry<K, V, U> entry)?, Set<U> unevictableUsers = const {}})

Properties

conflictPolicy ConflictPolicy
Used to determine what should be done in the case of a key conflict.
finalinherited
entries Iterable<CacheEntry<K, V, U>>
All items in the cache, in CacheEntry form.
no setterinherited
evictionPolicy EvictionPolicy
Used to determine which items to evict when the cache becomes full.
finalinherited
evictionStream Stream<CacheEntry<K, V, U>>
A stream of evicted cache entries.
no setterinherited
hashCode int
The hash code for this object.
no setterinherited
keys Iterable<K>
All of the keys in the cache.
no setterinherited
length int
The current number of items in the cache.
no setterinherited
onEvict → (void Function(CacheEntry<K, V, U> entry)?)
Will be called each time an item is evicted.
finalinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
size int
The maximum number of items the cache can hold.
finalinherited
unevictableUsers Set<U>
If an entry is used by any of these users, it cannot be evicted.
finalinherited
values Iterable<V>
All of the values in the cache.
no setterinherited

Methods

add(K key, V value, {ConflictPolicy? conflictPolicy, U? user, Set<U>? users}) → Result<CacheEntry<K, V, U>, CachetteError>
Adds a cache item with key and value. Use conflictPolicy to override the Cachette's conflict policy. If user or users are provided, they will be added to the cache item. Note that in order to use users, ConflictPolicy.users must be used. Try saying the previous sentence out loud quickly.
inherited
addUser(K key, U user) → Result<CacheEntry<K, V, U>, CachetteError>
Adds user to the cache item with key. Only works if the cache item already exists.
inherited
addUsers(K key, Set<U> users) → Result<CacheEntry<K, V, U>, CachetteError>
Adds users to the cache item with key. Only works if the cache item already exists.
inherited
clean({int? sizeLimit, EvictionPolicy? policy}) → Result<int, CachetteError>
Cleans the cache, i.e. removes enough cache items to meet sizeLimit. If sizeLimit isn't provided, the size of the Cachette is used, which is the most likely use case. policy can be used to override the Cachette's eviction policy.
inherited
clear() → void
Removes all items from the cache.
inherited
containsKey(K key) bool
Whether the cache contains an item with key.
inherited
gather(EvictionPolicy policy, int num) List<K>
Retries up to num items to be evicted according to policy.
inherited
get(K key) → Result<CacheEntry<K, V, U>, CachetteError>
Gets a cache item with key.
inherited
getUsers(K key) → Result<Set<U>, CachetteError>
Gets the list of all users registered to the cache item with key.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
remove(K key, {bool callOnEvict = false}) → Result<CacheEntry<K, V, U>, CachetteError>
Removes an item with key from the cache.
inherited
removeUser(K key, U user, {bool removeIfUnused = true, bool callOnEvict = true}) → Result<CacheEntry<K, V, U>, CachetteError>
Removes a single user from thee cache item with key. If removeIfUnused and the item has no users after removing user, it will be removed from the cache.
inherited
removeUsers(K key, Set<U> users, {bool removeIfUnused = true, bool callOnEvict = true}) → Result<CacheEntry<K, V, U>, CachetteError>
Removes users from thee cache item with key. If removeIfUnused and the item has no users after removing users, it will be removed from the cache.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited
operator [](K key) → V?
inherited
operator []=(K key, V value) → void
inherited