stash_api library Null safety

Standard caching API for Dart. Defines a common mechanism to create, access, update, and remove information from caches.

Classes

AccessedExpiryPolicy
An ExpiryPolicy that defines the expiry Duration of a Cache Entry based on the last time it was accessed. Accessed does not include a cache update.
BytesReader
Defines the base class supporting reads from a stream of bytes
BytesWriter
Defines the base class supporting writes to a stream of bytes
Cache
The Stash cache definition and the hub for the creation of the Cache caches
CacheCodec
Defines the contract of a binary codec that should be used for the serialization / deserealization of a value
CacheEntry
The wrapper around the object that is added to the cache
CacheEntryEvent
A Cache entry event base class.
CacheEvent
A Cache event base class.
CacheStat
Base class with all the stat fields backing up cache expiration and eviction strategies
CacheStore
The definition of a cache store
CreatedEntryEvent
A Cache entry created event
CreatedExpiryPolicy
An ExpiryPolicy that defines the expiry Duration of a Cache Entry based on when it was created. An update does not reset the expiry time.
DefaultCache
Default implementation of the Cache interface
EternalExpiryPolicy
An eternal ExpiryPolicy specifies that Cache Entries won't expire. This however doesn't mean they won't be evicted if an underlying implementation needs to free-up resources where by it may choose to evict entries that are not due to expire.
EvictedEntryEvent
A Cache entry evicted event
EvictionPolicy
Defines the eviction policy contract that every cache eviction algorithm should implement
ExpiredEntryEvent
A Cache entry expired event
ExpiryPolicy
Defines functions to determine when cache entries will expire based on creation, access and modification operations. [...]
FifoEvictionPolicy
Using this algorithm the cache behaves in the same way as a FIFO queue. The cache evicts the sampled entries in the order they were added, without any regard to how often or how many times they were accessed before. This algorithm uses CacheStat.creationTime to keep track of when a entry was created.
FiloEvictionPolicy
This algorithm the cache behaves in the same way as a stack and exact opposite way as a FIFO queue. The cache evicts the entry added most recently first without any regard to how often or how many times it was accessed before. This algorithm uses CacheStat.creationTime to keep track of when a entry was created.
FullSampler
A KeySampler that doesn't perform any sampling
KeySampler
Defines a strategy to sample elements from a cache key collection
LfuEvictionPolicy
Counts how often an item is needed. Those that are used least often are discarded first. This works very similar to LRU except that instead of storing the value of how recently a block was accessed, we store the value of how many times it was accessed. So of course while running an access sequence we will replace a entry which was used least number of times from our cache. E.g., if A was used (accessed) 5 times and B was used 3 times and others C and D were used 10 times each, we will replace B. This algorithm uses the CacheStat.hitCount to keep track of how many times a entry was uses.
LruEvictionPolicy
Discards the least recently used items first. This algorithm uses the CacheStat.accessTime to keep track of what was used when.
MfuEvictionPolicy
Counts how often an item is needed. Those that are used most often are discarded first. This works very similar to MRU except that instead of storing the value of how recently a block was accessed, we store the value of how many times it was accessed. So of course while running an access sequence we will replace a entry which was used most number of times from our cache. E.g., if A was used (accessed) 5 times and B was used 3 times and C was used 10 times, we will replace C. This algorithm uses the CacheStat.hitCount to keep track of how many times a entry was uses.
ModifiedExpiryPolicy
An ExpiryPolicy that defines the expiry Duration of a Cache Entry based on the last time it was updated. Updating includes created and changing (updating) an entry.
MruEvictionPolicy
Discards, in contrast to LRU, the most recently used items first. This algorithm uses the CacheStat.accessTime to keep track of what was used when.
RemovedEntryEvent
A Cache entry removed event
TieredCache
Tiered implementation of the Cache interface allowing the assignement of a primary and secondary caches. It was designed to be used with a primary Cache bound to a fast CacheStore and a secondary cache bound to a persistent CacheStore implementation
TouchedExpiryPolicy
An ExpiryPolicy that defines the expiry Duration of a Cache Entry based on when it was last touched. A touch includes creation, update or access.
UpdatedEntryEvent
A Cache entry updated event

Constants

float32Size → const int
Size of a float32 in bytes
4
float64Size → const int
Size of a float64 in bytes
8
int8Size → const int
Size of a int8 in bytes
1
int16Size → const int
Size of a int16 in bytes
2
int32Size → const int
Size of a int32 in bytes
4
int64Size → const int
Size of a int64 in bytes
8
uint8Size → const int
Size of a uint8 in bytes
1
uint16Size → const int
Size of a uint16 in bytes
2
uint32Size → const int
Size of a uint32 in bytes
4
uint64Size → const int
Size of a uint64 in bytes
8

Functions

newTieredCache(Cache primary, Cache secondary) Cache
Creates a new TieredCache with a primary and secondary Cache instances [...]

Enums

EntryEventType
The type of event received by the listener.
EventListenerMode

Typedefs

CacheLoader = Future Function(String key)
Cache loader function