-
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 openEditor.
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.SnapshotopenSnapshot(String key)Read the entry associated with key. abstract DiskCache.Snapshotget(String key)abstract DiskCache.EditoropenEditor(String key)Write to the entry associated with key. abstract DiskCache.Editoredit(String 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
-
openSnapshot
@ExperimentalCoilApi() abstract DiskCache.Snapshot openSnapshot(String key)
Read the entry associated with key.
IMPORTANT: You must call either Snapshot.close or Snapshot.closeAndOpenEditor when finished reading the snapshot. An open snapshot prevents opening a new Editor or deleting the entry on disk.
-
get
@Deprecated(message = Renamed to 'openSnapshot'., replaceWith = @ReplaceWith(imports = {}, expression = openSnapshot(key)))@ExperimentalCoilApi() abstract DiskCache.Snapshot get(String key)
-
openEditor
@ExperimentalCoilApi() abstract DiskCache.Editor openEditor(String key)
Write to the entry associated with key.
IMPORTANT: You must call one of Editor.commit, Editor.commitAndOpenSnapshot, or Editor.abort to complete the edit. An open editor prevents opening a new Snapshot, opening a new Editor, or deleting the entry on disk.
-
edit
@Deprecated(message = Renamed to 'openEditor'., replaceWith = @ReplaceWith(imports = {}, expression = openEditor(key)))@ExperimentalCoilApi() abstract DiskCache.Editor edit(String key)
-
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.
-
-
-
-