newCache<V> method
Creates a new cache
store
: TheStore
name
: The name of the cachefromEncodable
: The function that converts between the Map representation of the object and the object itself.expiryPolicy
: The expiry policy to usesampler
: The sampler to use upon eviction of a cache elementevictionPolicy
: The eviction policy to usemaxEntries
: The max number of entries this cache can hold if provided.cacheLoader
: TheCacheLoader
, that should be used to fetch a new value upon absence or expirationclock
: The source of time to be used on thiseventListenerMode
: The event listener mode of this cachestatsEnabled
: If statistics should be collected, defaults to falsestats
: The statistics instance
Implementation
Future<Cache<V>> newCache<V>(T store,
{String? name,
dynamic Function(Map<String, dynamic>)? fromEncodable,
ExpiryPolicy? expiryPolicy,
KeySampler? sampler,
EvictionPolicy? evictionPolicy,
int? maxEntries,
CacheLoader<V>? cacheLoader,
Clock? clock,
EventListenerMode? eventListenerMode,
bool? statsEnabled,
CacheStats? stats}) {
return newGenericCache<V, T>(store,
name: name,
fromEncodable: fromEncodable ?? generator.fromEncodable,
expiryPolicy: expiryPolicy,
sampler: sampler,
evictionPolicy: evictionPolicy,
maxEntries: maxEntries,
cacheLoader: cacheLoader,
clock: clock,
eventListenerMode: eventListenerMode,
statsEnabled: statsEnabled,
stats: stats);
}