-
public final class BufferedDiskCacheBufferedDiskCache provides get and put operations to take care of scheduling disk-cache read/writes.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public classBufferedDiskCache.Companion
-
Constructor Summary
Constructors Constructor Description BufferedDiskCache(FileCache fileCache, PooledByteBufferFactory pooledByteBufferFactory, PooledByteStreams pooledByteStreams, Executor readExecutor, Executor writeExecutor, ImageCacheStatsTracker imageCacheStatsTracker)
-
Method Summary
Modifier and Type Method Description final LonggetSize()final BooleancontainsSync(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 BooleandiskCheckSync(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 UnitaddKeyForAsyncProbing(CacheKey key)final Unitput(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. -
-
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.
-
diskCheckSync
final Boolean diskCheckSync(CacheKey key)
Performs disk cache check synchronously.
-
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.
-
addKeyForAsyncProbing
final Unit addKeyForAsyncProbing(CacheKey key)
-
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.
-
-
-
-