newMemoryCache function

Cache newMemoryCache({
  1. String? cacheName,
  2. ExpiryPolicy? expiryPolicy,
  3. KeySampler? sampler,
  4. EvictionPolicy? evictionPolicy,
  5. int? maxEntries,
  6. CacheLoader? cacheLoader,
})

Creates a new Cache backed by a MemoryStore

  • 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

Returns a Cache backed by a MemoryStore

Implementation

Cache newMemoryCache(
    {String? cacheName,
    ExpiryPolicy? expiryPolicy,
    KeySampler? sampler,
    EvictionPolicy? evictionPolicy,
    int? maxEntries,
    CacheLoader? cacheLoader}) {
  return Cache.newCache(MemoryStore(),
      name: cacheName,
      expiryPolicy: expiryPolicy,
      sampler: sampler,
      evictionPolicy: evictionPolicy,
      maxEntries: maxEntries,
      cacheLoader: cacheLoader);
}