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<
T> - The cache definition and the hub for the creation of caches
- CacheEntry
- The wrapper around the object that is added to the cache
-
CacheEntryBuilder<
T> - The CacheEntry builder
-
CacheEntryCreatedEvent<
T> - The entry created event
-
CacheEntryEvictedEvent<
T> - A cache entry evicted event
-
CacheEntryExpiredEvent<
T> - A cache entry expired event
-
CacheEntryRemovedEvent<
T> - A cache entry removed event
-
CacheEntryUpdatedEvent<
T> - A Cache entry updated event
-
CacheEvent<
T> - A Cache event
- CacheInfo
- Base class with all the info fields for the Cache
- CacheManager
- CacheStats
-
The
Stats
definition for a cache - CacheStore
- 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.
- DefaultCacheManager
- DefaultVaultManager
-
Entry<
T extends Info> -
EntryBuilder<
T, I extends Info, E extends Entry< I> > - The Entry builder
- 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 CacheInfo.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 CacheInfo.creationTime to keep track of when a entry was created.
- FullSampler
- A sampler that doesn't perform any sampling
-
GenericCache<
T> - Generic implementation of the Cache interface
-
GenericVault<
T> - Generic implementation of the Vault interface
- HyperbolicEvictionPolicy
- Discards based on how frequently the entries are used divided by their age.
- Info
- Base class with all the info fields
- KeySampler
- Defines a strategy to sample elements from a 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 CacheInfo.hitCount to keep track of how many times a entry was uses.
- LruEvictionPolicy
- Discards the least recently used items first. This algorithm uses the CacheInfo.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 CacheInfo.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 CacheInfo.accessTime to keep track of what was used when.
-
PersistenceStore<
I extends Info, E extends Entry< I> > - A definition of a stores that persists data
-
Stash<
T> - The stash definition
-
StashEvent<
T, E extends Enum, S extends Stash< T> > - A stash event base class.
-
Store<
I extends Info, E extends Entry< I> > - Store definition
- StoreCodec
- Defines the contract of a binary codec that should be used for the serialization / deserealization of a value
-
TieredCache<
T> - 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 store and a secondary cache bound to a persistent store 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.
-
Vault<
T> - The vault definition and the hub for the creation of Vaults
- VaultEntry
- The wrapper around the object that added to the vault
-
VaultEntryBuilder<
T> - The VaultEntry builder
-
VaultEntryCreatedEvent<
T> - The entry created event
-
VaultEntryRemovedEvent<
T> - A vault entry removed event
-
VaultEntryUpdatedEvent<
T> - A Vault entry updated event
-
VaultEvent<
T> - A Cache event
- VaultInfo
- Base class with all the info fields for the Vault
- VaultManager
- VaultStats
-
The
Stats
definition for a vault - VaultStore
Enums
- CacheEventType
- The type of event received by the listener.
- EntryState
- The state of the Entry
- EventListenerMode
- ValueProcessor
- Value processor
- VaultEventType
- The type of event received by the listener.
Extensions
-
CacheExtension
on Store<
CacheInfo, CacheEntry> - Extension over Store allowing the creation of multiple caches from the same store
-
StashExtension
on Stash<
T> - Extension over Stash to add some helper methods
-
VaultExtension
on Store<
VaultInfo, VaultEntry> - Extension over Store allowing the creation of multiple vaults from the same store
Constants
- float32Size → const int
- Size of a float32 in bytes
- float64Size → const int
- Size of a float64 in bytes
- int16Size → const int
- Size of a int16 in bytes
- int32Size → const int
- Size of a int32 in bytes
- int64Size → const int
- Size of a int64 in bytes
- int8Size → const int
- Size of a int8 in bytes
- uint16Size → const int
- Size of a uint16 in bytes
- uint32Size → const int
- Size of a uint32 in bytes
- uint64Size → const int
- Size of a uint64 in bytes
- uint8Size → const int
- Size of a uint8 in bytes
Functions
-
newTieredCache<
T> (CacheManager? manager, Cache< T> primary, Cache<T> secondary, {String? name, bool? statsEnabled, CacheStats? stats}) → Cache<T> - Builds a new Tiered Cache
Typedefs
-
CacheEntryDelegate<
T> = CacheEntryBuilder< T> Function(CacheEntryBuilder<T> delegate) - Cache entry delegate
-
CacheLoader<
T> = Future< T> Function(String key) - Cache loader function
-
VaultEntryDelegate<
T> = VaultEntryBuilder< T> Function(VaultEntryBuilder<T> delegate) - Vault entry delegate
-
VaultLoader<
T> = Future< T> Function(String key) - Vault loader function