cache<T> method
Future<Cache<T> >
cache<T>({
- CacheManager? manager,
- String? name,
- dynamic fromEncodable()?,
- KeySampler? sampler,
- EvictionPolicy? evictionPolicy,
- int? maxEntries,
- ExpiryPolicy? expiryPolicy,
- CacheLoader<
T> ? cacheLoader, - EventListenerMode? eventListenerMode,
- bool? statsEnabled,
- CacheStats? stats,
Creates a new Cache backed by a Store
manager
: An optional CacheManagername
: 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. To trigger the eviction policy this value should be providedcacheLoader
: The CacheLoader that should be used to fetch a new value upon absence or expirationeventListenerMode
: The event listener mode of this cachestatsEnabled
: If statistics should be collected, defaults to falsestats
: The statistics instance
Implementation
Future<Cache<T>> cache<T>(
{CacheManager? manager,
String? name,
dynamic Function(Map<String, dynamic>)? fromEncodable,
KeySampler? sampler,
EvictionPolicy? evictionPolicy,
int? maxEntries,
ExpiryPolicy? expiryPolicy,
CacheLoader<T>? cacheLoader,
EventListenerMode? eventListenerMode,
bool? statsEnabled,
CacheStats? stats}) {
return _newGenericCache<T>(this,
manager: manager,
name: name,
fromEncodable: fromEncodable,
expiryPolicy: expiryPolicy,
sampler: sampler,
evictionPolicy: evictionPolicy,
maxEntries: maxEntries,
cacheLoader: cacheLoader,
eventListenerMode: eventListenerMode,
statsEnabled: statsEnabled,
stats: stats);
}