DefaultCacheManager constructor
DefaultCacheManager({
- Duration stalePeriod = _kDefaultStalePeriod,
- int maxNrOfCacheObjects = _kDefaultMaxCacheObjects,
- Client httpClientFactory()?,
- CacheDirectoryProvider? cacheDirectoryProvider,
Creates a DefaultCacheManager with optional configuration.
stalePeriod is how long a file remains valid in the cache.
maxNrOfCacheObjects is the maximum before cleanup triggers.
httpClientFactory allows injecting a custom HTTP client (useful for testing).
cacheDirectoryProvider allows overriding where cache files are stored.
Defaults to getTemporaryDirectory. Pass getApplicationSupportDirectory
if you need a more persistent location (but note that files may be
backed up on iOS/Android).
Implementation
DefaultCacheManager({
this.stalePeriod = _kDefaultStalePeriod,
this.maxNrOfCacheObjects = _kDefaultMaxCacheObjects,
http.Client Function()? httpClientFactory,
CacheDirectoryProvider? cacheDirectoryProvider,
}) : _httpClientFactory = httpClientFactory ?? http.Client.new,
_cacheDirectoryProvider =
cacheDirectoryProvider ?? getTemporaryDirectory;