Package 

Class BufferedDiskCache


  • 
    public final class BufferedDiskCache
    
                        

    BufferedDiskCache provides get and put operations to take care of scheduling disk-cache read/writes.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private final Long size
    • Method Summary

      Modifier and Type Method Description
      final Long getSize()
      final Boolean containsSync(CacheKey key) Returns true if the key is in the in-memory key index.
      final Task<Boolean> contains(CacheKey key) Performs a key-value look up in the disk cache.
      final Boolean diskCheckSync(CacheKey key) Performs disk cache check synchronously.
      final Task<EncodedImage> get(CacheKey key, AtomicBoolean isCancelled) Performs key-value look up in disk cache.
      final Task<Void> probe(CacheKey key) Performs key-value look up in disk cache.
      final Unit addKeyForAsyncProbing(CacheKey key)
      final Unit put(CacheKey key, EncodedImage encodedImage) Associates encodedImage with given key in disk cache.
      final Task<Void> remove(CacheKey key) Removes the item from the disk cache and the staging area.
      final Task<Void> clearAll() Clears the disk cache and the staging area.
      • Methods inherited from class java.lang.Object

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

      • BufferedDiskCache

        BufferedDiskCache(FileCache fileCache, PooledByteBufferFactory pooledByteBufferFactory, PooledByteStreams pooledByteStreams, Executor readExecutor, Executor writeExecutor, ImageCacheStatsTracker imageCacheStatsTracker)
    • Method Detail

      • containsSync

         final Boolean containsSync(CacheKey key)

        Returns true if the key is in the in-memory key index.

        Not guaranteed to be correct. The cache may yet have this key even if this returns false. But if it returns true, it definitely has it.

        Avoids a disk read.

      • contains

         final Task<Boolean> contains(CacheKey key)

        Performs a key-value look up in the disk cache. If no value is found in the staging area, then disk cache checks are scheduled on a background thread. Any error manifests itself as a cache miss, i.e. the returned Task resolves to false.

      • get

         final Task<EncodedImage> get(CacheKey key, AtomicBoolean isCancelled)

        Performs key-value look up in disk cache. If value is not found in disk cache staging area then disk cache read is scheduled on background thread. Any error manifests itself as cache miss, i.e. the returned task resolves to null.

      • probe

         final Task<Void> probe(CacheKey key)

        Performs key-value look up in disk cache. If value is not found in disk cache staging area then disk cache probing is scheduled on background thread.

      • put

         final Unit put(CacheKey key, EncodedImage encodedImage)

        Associates encodedImage with given key in disk cache. Disk write is performed on background thread, so the caller of this method is not blocked

      • remove

         final Task<Void> remove(CacheKey key)

        Removes the item from the disk cache and the staging area.

      • clearAll

         final Task<Void> clearAll()

        Clears the disk cache and the staging area.