AlfredCache<T> constructor

AlfredCache<T>({
  1. required T fromEncodable(
    1. Map<String, dynamic>
    ),
  2. String? path,
  3. int maxEntries = 10,
  4. String name = 'query_cache',
  5. EvictionPolicy evictionPolicy = const LruEvictionPolicy(),
  6. ExpiryPolicy expiryPolicy = const CreatedExpiryPolicy(Duration(minutes: 1)),
  7. bool verbose = false,
})

Builds an AlfredCache providing a Cache backed by a Store

  • fromEncodable : A custom function the converts to the object from a Map<String, dynamic> representation
  • path : Optionally customize the base storage location for this store
  • maxEntries : The max number of entries this cache can hold if provided. Defaults to 10.
  • name : The name of the cache. Defaults to "query_cache".
  • evictionPolicy : Optionally customize the EvictionPolicy. Defaults to LruEvictionPolicy
  • expiryPolicy : Optionally customize the ExpiryPolicy. Defaults to CreatedExpiryPolicy with a Duration of 1 minute.
  • verbose : If set to true then listeners will print events to the developer log. Defaults to false.

Implementation

AlfredCache({
  required this.fromEncodable,
  this.path,
  this.maxEntries = 10,
  this.name = 'query_cache',
  this.evictionPolicy = const LruEvictionPolicy(),
  this.expiryPolicy = const CreatedExpiryPolicy(Duration(minutes: 1)),
  this.verbose = false,
}) : assert(maxEntries > 0, 'maxEntries must be positive number');