newLazyHiveCache function

Cache newLazyHiveCache(
  1. String path, {
  2. String? cacheName,
  3. ExpiryPolicy? expiryPolicy,
  4. KeySampler? sampler,
  5. EvictionPolicy? evictionPolicy,
  6. int? maxEntries,
  7. CacheLoader? cacheLoader,
  8. dynamic fromEncodable(
    1. dynamic
    )?,
  9. HiveCipher? encryptionCipher,
  10. bool? crashRecovery,
})

Creates a new Cache backed by a HiveLazyStore

  • path: The base storage location for this cache
  • cacheName: The name of the cache
  • expiryPolicy: The expiry policy to use, defaults to EternalExpiryPolicy if not provided
  • 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
  • cacheLoader: The CacheLoader that should be used to fetch a new value upon expiration
  • fromEncodable: A custom function the converts to the object from a Map<String, dynamic> representation

Returns a new Cache backed by a HiveLazyStore

Implementation

Cache newLazyHiveCache(String path,
    {String? cacheName,
    ExpiryPolicy? expiryPolicy,
    KeySampler? sampler,
    EvictionPolicy? evictionPolicy,
    int? maxEntries,
    CacheLoader? cacheLoader,
    dynamic Function(dynamic)? fromEncodable,
    HiveCipher? encryptionCipher,
    bool? crashRecovery}) {
  return Cache.newCache(
      HiveLazyStore(
          HiveLazyAdapter(path,
              encryptionCipher: encryptionCipher, crashRecovery: crashRecovery),
          fromEncodable: fromEncodable),
      name: cacheName,
      expiryPolicy: expiryPolicy,
      sampler: sampler,
      evictionPolicy: evictionPolicy,
      maxEntries: maxEntries,
      cacheLoader: cacheLoader);
}