newCache<V> method

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

Creates a new cache

  • store: The Store
  • 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.
  • cacheLoader: The CacheLoader, that should be used to fetch a new value upon absence or expiration
  • clock: The source of time to be used on this
  • eventListenerMode: The event listener mode of this cache
  • statsEnabled: If statistics should be collected, defaults to false
  • stats: 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);
}