newSembastFileCache function

Cache newSembastFileCache({
  1. String? path,
  2. String? cacheName,
  3. KeySampler? sampler,
  4. EvictionPolicy? evictionPolicy,
  5. int? maxEntries,
  6. ExpiryPolicy? expiryPolicy,
  7. CacheLoader? cacheLoader,
  8. EventListenerMode? eventListenerMode,
  9. CacheStore? store,
  10. dynamic fromEncodable(
    1. dynamic
    )?,
  11. int? databaseVersion,
  12. OnVersionChangedFunction? onVersionChanged,
  13. DatabaseMode? databaseMode,
  14. SembastCodec? sembastCodec,
})

Creates a new Cache backed by a SembastStore

  • path: The location of this store, if not provided defaults to "stash_sembast.db"
  • cacheName: The name of the cache
  • sampler: The sampler to use upon eviction of a cache element, defaults to FullSampler if not provided
  • evictionPolicy: The eviction policy to use, defaults to LfuEvictionPolicy if not provided
  • maxEntries: The max number of entries this cache can hold if provided. To trigger the eviction policy this value should be provided
  • expiryPolicy: The expiry policy to use, defaults to EternalExpiryPolicy if not provided
  • cacheLoader: The CacheLoader that should be used to fetch a new value upon expiration
  • eventListenerMode: The event listener mode of this cache
  • store: An existing store, note that fromEncodable, databaseVersion, onVersionChanged, databaseMode and sembastCodec will be all ignored is this parameter is provided
  • fromEncodable: A custom function the converts to the object from a Map<String, dynamic> representation
  • databaseVersion: The expected version
  • onVersionChanged: If databaseVersion not null and if the existing version is different, onVersionChanged is called
  • databaseMode: The database mode
  • sembastCodec: The codec which can be used to load/save a record, allowing for user encryption

Returns a new Cache backed by a SembastStore

Implementation

Cache newSembastFileCache(
    {String? path,
    String? cacheName,
    KeySampler? sampler,
    EvictionPolicy? evictionPolicy,
    int? maxEntries,
    ExpiryPolicy? expiryPolicy,
    CacheLoader? cacheLoader,
    EventListenerMode? eventListenerMode,
    CacheStore? store,
    dynamic Function(dynamic)? fromEncodable,
    int? databaseVersion,
    OnVersionChangedFunction? onVersionChanged,
    DatabaseMode? databaseMode,
    SembastCodec? sembastCodec}) {
  return newSembastCache(
      newSembastFileStore(
          path: path,
          fromEncodable: fromEncodable,
          databaseVersion: databaseVersion,
          onVersionChanged: onVersionChanged,
          databaseMode: databaseMode,
          sembastCodec: sembastCodec),
      cacheName: cacheName,
      sampler: sampler,
      evictionPolicy: evictionPolicy,
      maxEntries: maxEntries,
      expiryPolicy: expiryPolicy,
      cacheLoader: cacheLoader,
      eventListenerMode: eventListenerMode);
}