-
public interface DiskCacheAn LRU cache of files.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public interfaceDiskCache.SnapshotA snapshot of the values for an entry.
IMPORTANT: You must only readmetadata or data. Mutating either file can corrupt the disk cache. To modify the contents of those files, use edit.
public interfaceDiskCache.EditorEdits the values for an entry.
Calling metadata or data marks that file as dirty so it will be persisted to disk if this editor is committed.
IMPORTANT: You must only read or modify the contents of metadata or data. Renaming, locking, or other mutating file operations can corrupt the disk cache.
public final classDiskCache.Builder
-
Method Summary
Modifier and Type Method Description abstract DiskCache.Snapshotget(String key)Get the entry associated with key. abstract DiskCache.Editoredit(String key)Edit the entry associated with key. abstract Booleanremove(String key)Delete the entry referenced by key. abstract Unitclear()Delete all entries in the disk cache. abstract LonggetSize()The current size of the cache in bytes. abstract LonggetMaxSize()The maximum size of the cache in bytes. abstract PathgetDirectory()The directory where the cache stores its data. abstract FileSystemgetFileSystem()The file system that contains the cache's files. -
-
Method Detail
-
get
@ExperimentalCoilApi() abstract DiskCache.Snapshot get(String key)
Get the entry associated with key.
IMPORTANT: You must call either Snapshot.close or Snapshot.closeAndEdit when finished reading the snapshot. An open snapshot prevents editing the entry or deleting it on disk.
-
edit
@ExperimentalCoilApi() abstract DiskCache.Editor edit(String key)
Edit the entry associated with key.
IMPORTANT: You must call one of Editor.commit, Editor.commitAndGet, or Editor.abort to complete the edit. An open editor prevents opening new Snapshots or opening a new Editor.
-
remove
@ExperimentalCoilApi() abstract Boolean remove(String key)
Delete the entry referenced by key.
-
clear
@ExperimentalCoilApi() abstract Unit clear()
Delete all entries in the disk cache.
-
getMaxSize
abstract Long getMaxSize()
The maximum size of the cache in bytes.
-
getDirectory
abstract Path getDirectory()
The directory where the cache stores its data.
-
getFileSystem
abstract FileSystem getFileSystem()
The file system that contains the cache's files.
-
-
-
-