cache<T> method

Future<Cache<T>> cache<T>({
  1. CacheManager? manager,
  2. String? name,
  3. dynamic fromEncodable(
    1. Map<String, dynamic>
    )?,
  4. KeySampler? sampler,
  5. EvictionPolicy? evictionPolicy,
  6. int? maxEntries,
  7. ExpiryPolicy? expiryPolicy,
  8. CacheLoader<T>? cacheLoader,
  9. EventListenerMode? eventListenerMode,
  10. bool? statsEnabled,
  11. CacheStats? stats,
})

Creates a new Cache backed by a Store

  • manager: An optional CacheManager
  • name: The name of the cache
  • fromEncodable: The function that converts between the Map representation of the object and the object itself.
  • expiryPolicy: The expiry policy to use
  • sampler: The sampler to use upon eviction of a cache element
  • evictionPolicy: The eviction policy to use
  • maxEntries: The max number of entries this cache can hold if provided. To trigger the eviction policy this value should be provided
  • cacheLoader: The CacheLoader that should be used to fetch a new value upon absence or expiration
  • eventListenerMode: The event listener mode of this cache
  • statsEnabled: If statistics should be collected, defaults to false
  • stats: The statistics instance

Returns a Cache backed by a Store

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);
}