newLocalDiskCache function
Cache
newLocalDiskCache({})
Creates a new Cache
backed by a local DiskStore
path
: The base storage location for this cachecacheName
: The name of the cacheexpiryPolicy
: The expiry policy to use, defaults toEternalExpiryPolicy
if not providedsampler
: The sampler to use upon eviction of a cache element, defaults toFullSampler
if not providedevictionPolicy
: The eviction policy to use, defaults toLfuEvictionPolicy
if not providedmaxEntries
: The max number of entries this cache can hold if provided. To trigger the eviction policy this value should be providedcacheLoader
: TheCacheLoader
that should be used to fetch a new value upon expirationcodec
: TheCacheCodec
used to convert to/from a Map<String, dynamic>` representation to a binary representationfromEncodable
: A custom function the converts to the object from aMap<String, dynamic>
representation
Returns a new Cache
backed by a DiskStore
Implementation
Cache newLocalDiskCache(
{String? path,
String? cacheName,
ExpiryPolicy? expiryPolicy,
KeySampler? sampler,
EvictionPolicy? evictionPolicy,
int? maxEntries,
CacheLoader? cacheLoader,
CacheCodec? codec,
dynamic Function(dynamic)? fromEncodable}) {
FileSystem fs = const LocalFileSystem();
return Cache.newCache(
DiskStore(fs, path ?? fs.systemTempDirectory.path,
codec: codec, fromEncodable: fromEncodable),
name: cacheName,
expiryPolicy: expiryPolicy,
sampler: sampler,
evictionPolicy: evictionPolicy,
maxEntries: maxEntries,
cacheLoader: cacheLoader);
}