Class GlobalOkHttpDiskCacheManager
-
- All Implemented Interfaces:
public final class GlobalOkHttpDiskCacheManagerClass that manages creation of global OKHttp's Cache.
Cache size is based on Android's provided StorageManager.getCacheQuotaBytes method. That way we can achieve best balance between having big cache and not eating up user's disk space.
To create cache, just access cache object. Please note that the operations makes some blocking disk accesses and thus, first call to cache MUST be done on the worker thread.
-
-
Field Summary
Fields Modifier and Type Field Description private final Cachecache
-
Constructor Summary
Constructors Constructor Description GlobalOkHttpDiskCacheManager(Context context, ErrorReporter errorReporter, Long fallbackCacheSize, String cacheSubfolderName, Float cacheQuotaFraction)
-
Method Summary
Modifier and Type Method Description final CachegetCache()-
-
Constructor Detail
-
GlobalOkHttpDiskCacheManager
GlobalOkHttpDiskCacheManager(Context context, ErrorReporter errorReporter, Long fallbackCacheSize, String cacheSubfolderName, Float cacheQuotaFraction)
- Parameters:
fallbackCacheSize- Cache size in bytes if we cannot get the quota from the Android system (for example due to older API level)cacheSubfolderName- Name of the subfolder inside cache folder where OkHttp cache will be createdcacheQuotaFraction- Fraction of the total cache quota that can be used for OkHttp Disk cache.
-
-
Method Detail
-
getCache
@WorkerThread() final Cache getCache()
-
-
-
-