newMemoryCacheInterceptor function

Interceptor newMemoryCacheInterceptor(
  1. String pattern,
  2. String cacheName, {
  3. KeySampler? sampler,
  4. EvictionPolicy? evictionPolicy,
  5. int? maxEntries,
  6. ExpiryPolicy? expiryPolicy,
  7. CacheLoader? cacheLoader,
  8. EventListenerMode? eventListenerMode,
  9. MemoryStore? store,
})

Creates a new Interceptor backed by a Cache with MemoryStore storage

  • pattern: All the calls with a url matching this pattern will be cached
  • 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

Returns a Interceptor

Implementation

Interceptor newMemoryCacheInterceptor(String pattern, String cacheName,
    {KeySampler? sampler,
    EvictionPolicy? evictionPolicy,
    int? maxEntries,
    ExpiryPolicy? expiryPolicy,
    CacheLoader? cacheLoader,
    EventListenerMode? eventListenerMode,
    MemoryStore? store}) {
  return newCacheInterceptor(
      pattern,
      newMemoryCache(
          cacheName: cacheName,
          evictionPolicy: evictionPolicy,
          sampler: sampler,
          expiryPolicy: expiryPolicy,
          maxEntries: maxEntries,
          cacheLoader: cacheLoader,
          eventListenerMode: eventListenerMode,
          store: store));
}