public class StackedFileHashCache extends Object implements FileHashCache
ProjectFilesystem-specific ProjectFileHashCaches as a
single cache, implementing a Chain of Responsibility to find and forward operations to the
correct inner cache. As this "multi"-cache is meant to handle paths across different ProjectFilesystems, as opposed to paths within the same ProjectFilesystem, it is a
distinct type from ProjectFileHashCache.
This "stacking" approach provides a few appealing properties:
ProjectFileHashCaches per path root, we can
construct a new StackedFileHashCache on each build composed of either persistent or
ephemeral per-root inner caches that properly manager the lifetime of cached hashes from
their root.
FileHashCache.FileHashCacheVerificationResult| Constructor and Description |
|---|
StackedFileHashCache(com.google.common.collect.ImmutableList<? extends ProjectFileHashCache> caches) |
| Modifier and Type | Method and Description |
|---|---|
static StackedFileHashCache |
createDefaultHashCaches(ProjectFilesystem filesystem,
FileHashCacheMode fileHashCacheMode) |
java.util.stream.Stream<Map.Entry<Path,com.google.common.hash.HashCode>> |
debugDump() |
com.google.common.hash.HashCode |
get(Path path) |
com.google.common.hash.HashCode |
get(ProjectFilesystem filesystem,
Path path)
|
com.google.common.collect.ImmutableList<? extends ProjectFileHashCache> |
getCaches() |
com.google.common.hash.HashCode |
getForArchiveMember(Path relativeArchivePath,
Path memberPath) |
com.google.common.hash.HashCode |
getForArchiveMember(ProjectFilesystem filesystem,
Path relativeArchivePath,
Path memberPath)
|
long |
getSize(Path path) |
long |
getSize(ProjectFilesystem filesystem,
Path path)
Return the size of the given relative
Path under the given ProjectFilesystem. |
void |
invalidate(Path path) |
void |
invalidateAll() |
StackedFileHashCache |
newDecoratedFileHashCache(java.util.function.Function<ProjectFileHashCache,ProjectFileHashCache> decorateDelegate) |
void |
set(Path path,
com.google.common.hash.HashCode hashCode) |
void |
set(ProjectFilesystem filesystem,
Path path,
com.google.common.hash.HashCode hashCode)
|
FileHashCache.FileHashCacheVerificationResult |
verify() |
public StackedFileHashCache(com.google.common.collect.ImmutableList<? extends ProjectFileHashCache> caches)
public static StackedFileHashCache createDefaultHashCaches(ProjectFilesystem filesystem, FileHashCacheMode fileHashCacheMode)
public void invalidate(Path path)
invalidate in interface FileHashCachepublic void invalidateAll()
invalidateAll in interface FileHashCachepublic com.google.common.hash.HashCode get(Path path) throws IOException
get in interface FileHashLoaderIOExceptionpublic long getSize(Path path) throws IOException
getSize in interface FileHashLoaderIOExceptionpublic com.google.common.hash.HashCode getForArchiveMember(Path relativeArchivePath, Path memberPath) throws IOException
getForArchiveMember in interface FileHashLoaderIOExceptionpublic void set(Path path, com.google.common.hash.HashCode hashCode) throws IOException
set in interface FileHashCacheIOExceptionpublic FileHashCache.FileHashCacheVerificationResult verify() throws IOException
verify in interface FileHashCacheIOExceptionpublic java.util.stream.Stream<Map.Entry<Path,com.google.common.hash.HashCode>> debugDump()
debugDump in interface FileHashCachepublic com.google.common.hash.HashCode get(ProjectFilesystem filesystem, Path path) throws IOException
FileHashLoaderget in interface FileHashLoaderIOExceptionpublic com.google.common.hash.HashCode getForArchiveMember(ProjectFilesystem filesystem, Path relativeArchivePath, Path memberPath) throws IOException
FileHashLoadergetForArchiveMember in interface FileHashLoaderIOExceptionpublic long getSize(ProjectFilesystem filesystem, Path path) throws IOException
FileHashLoaderPath under the given ProjectFilesystem.getSize in interface FileHashLoaderIOExceptionpublic void set(ProjectFilesystem filesystem, Path path, com.google.common.hash.HashCode hashCode) throws IOException
FileHashCacheset in interface FileHashCacheIOExceptionpublic StackedFileHashCache newDecoratedFileHashCache(java.util.function.Function<ProjectFileHashCache,ProjectFileHashCache> decorateDelegate)
public com.google.common.collect.ImmutableList<? extends ProjectFileHashCache> getCaches()