Class DiskLruCache

  • All Implemented Interfaces:

    
    public abstract class DiskLruCache<T extends Object>
    
                        

    A disk-based LRU cache for storing data.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      final File getCacheDirectory() The directory where the cache files are stored.
      final Long getCacheSizeLimit() The effective cache size limit in bytes.
      final T get(String key) Get data from disk cache
      abstract T readFromFile(File file)
      final Unit put(String key, T value) Put data to disk cache
      abstract Unit writeToFile(File file, T value)
      final Unit remove(String key) Remove data from cache
      final Unit clear() Clear all cached files
      final Long size() Get current cache size in bytes
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • DiskLruCache

        DiskLruCache(String cacheDir, Long maxSize, Float diskSpaceAllocationRatio)
        Parameters:
        cacheDir - cache directory name
        maxSize - maximum size of the cache in bytes
        diskSpaceAllocationRatio - disk space allocation ratio for the cache