Class GlobalOkHttpDiskCacheManager

  • All Implemented Interfaces:

    
    public final class GlobalOkHttpDiskCacheManager
    
                        

    Class 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.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private final Cache cache
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      final Cache getCache()
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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 created
        cacheQuotaFraction - Fraction of the total cache quota that can be used for OkHttp Disk cache.