A - access typepublic class DiskCellCache<A> extends Object implements CacheRemover<Long,Cell<A>,A>, CacheLoader<Long,Cell<A>>
CacheRemover/CacheLoader for writing/reading cells
to a disk cache. Currently blocks are simply written as flat files to a
specified directory. createTempDirectory(String, boolean) can be
used to create a temporary directory that will be automatically removed when
the JVM shuts down.
Blocks which are not in the diskcache (yet) are obtained from a backing
CacheLoader.
A DiskCellCache should be connected to a in-memory cache through
IoSync if the cache will be used concurrently by multiple threads!
defaultParallelismThreshold| Constructor and Description |
|---|
DiskCellCache(Path blockcache,
CellGrid grid,
CacheLoader<Long,Cell<A>> backingLoader,
AccessIo<A> accessIo,
Fraction entitiesPerPixel) |
| Modifier and Type | Method and Description |
|---|---|
static void |
addDeleteHook(Path path)
Register a path for deletion when the virtual machine shuts down.
|
static Path |
createTempDirectory(Path dir,
String prefix,
boolean deleteOnExit)
Creates a new directory in the specified directory, using the given
prefix to generate its name.
|
static Path |
createTempDirectory(String prefix,
boolean deleteOnExit)
Creates a new directory in the default temporary-file directory, using
the given prefix to generate its name.
|
A |
extract(Cell<A> value)
Extract data out of
value. |
Cell<A> |
get(Long key) |
void |
invalidate(Long key)
Removes the file for the given
key (if it exists). |
void |
invalidateAll(long parallelismThreshold)
Removes all files.
|
void |
invalidateIf(long parallelismThreshold,
Predicate<Long> condition)
Removes all files for keys matching the given
condition. |
void |
onRemoval(Long key,
A valueData)
Called when an entry is evicted from the cache.
|
CompletableFuture<Void> |
persist(Long key,
A valueData)
TODO
|
Cell<A> |
reconstruct(Long key,
A valueData)
Construct a value from its
key and valueData. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitinvalidateAll, invalidateIfpublic A extract(Cell<A> value)
CacheRemovervalue. The data must be sufficient to
reconstruct an identical value, and must not contain any references to
value.public Cell<A> reconstruct(Long key, A valueData)
CacheRemoverkey and valueData.reconstruct in interface CacheRemover<Long,Cell<A>,A>public void onRemoval(Long key, A valueData)
CacheRemoverpublic CompletableFuture<Void> persist(Long key, A valueData)
CacheRemoverpublic void invalidate(Long key)
key (if it exists).invalidate in interface CacheRemover<Long,Cell<A>,A>invalidate in interface Invalidate<Long>key - key of the entry to removepublic void invalidateIf(long parallelismThreshold,
Predicate<Long> condition)
condition.invalidateIf in interface CacheRemover<Long,Cell<A>,A>invalidateIf in interface Invalidate<Long>parallelismThreshold - ignoredcondition - condition on keys of entries to removepublic void invalidateAll(long parallelismThreshold)
invalidateAll in interface CacheRemover<Long,Cell<A>,A>invalidateAll in interface Invalidate<Long>parallelismThreshold - ignoredpublic static void addDeleteHook(Path path)
path is a directory, it is deleted recursively.path - path to delete on virtual machine shutdown.public static Path createTempDirectory(Path dir, String prefix, boolean deleteOnExit) throws IOException
dir - the path to directory in which to create the directoryprefix - the prefix string to be used in generating the directory's
name; may be nulldeleteOnExit - whether the created directory should be automatically deleted
when the virtual machine shuts down.IOExceptionpublic static Path createTempDirectory(String prefix, boolean deleteOnExit) throws IOException
prefix - the prefix string to be used in generating the directory's
name; may be nulldeleteOnExit - whether the created directory should be automatically deleted
when the virtual machine shuts down.IOExceptionCopyright © 2015–2022 ImgLib2. All rights reserved.