stash_api library

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
CacheStat
Base class with all the stat fields backing up cache expiration and eviction strategies
CacheStore
The definition of a cache store
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.
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.
EvictionPolicy
Defines the eviction policy contract that every cache eviction algorithm should implement
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.
MsgpackCodec
Msgpack binary codec 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.

Constants

float32_size → const int
Size of a float32 in bytes
float64_size → const int
Size of a float64 in bytes
int16_size → const int
Size of a int16 in bytes
int32_size → const int
Size of a int32 in bytes
int64_size → const int
Size of a int64 in bytes
int8_size → const int
Size of a int8 in bytes
uint16_size → const int
Size of a uint16 in bytes
uint32_size → const int
Size of a uint32 in bytes
uint64_size → const int
Size of a uint64 in bytes
uint8_size → const int
Size of a uint8 in bytes

Functions

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

Typedefs

CacheLoader = Future Function(String key)
Cache loader function