public class StackedFileHashCache extends Object implements FileHashCache
ProjectFilesystem
-specific ProjectFileHashCache
s 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 ProjectFilesystem
s, as opposed to paths within the same ProjectFilesystem
, it is a
distinct type from ProjectFileHashCache
.
This "stacking" approach provides a few appealing properties:
ProjectFileHashCache
s 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 FileHashCache
public void invalidateAll()
invalidateAll
in interface FileHashCache
public com.google.common.hash.HashCode get(Path path) throws IOException
get
in interface FileHashLoader
IOException
public long getSize(Path path) throws IOException
getSize
in interface FileHashLoader
IOException
public com.google.common.hash.HashCode getForArchiveMember(Path relativeArchivePath, Path memberPath) throws IOException
getForArchiveMember
in interface FileHashLoader
IOException
public void set(Path path, com.google.common.hash.HashCode hashCode) throws IOException
set
in interface FileHashCache
IOException
public FileHashCache.FileHashCacheVerificationResult verify() throws IOException
verify
in interface FileHashCache
IOException
public java.util.stream.Stream<Map.Entry<Path,com.google.common.hash.HashCode>> debugDump()
debugDump
in interface FileHashCache
public com.google.common.hash.HashCode get(ProjectFilesystem filesystem, Path path) throws IOException
FileHashLoader
get
in interface FileHashLoader
IOException
public com.google.common.hash.HashCode getForArchiveMember(ProjectFilesystem filesystem, Path relativeArchivePath, Path memberPath) throws IOException
FileHashLoader
getForArchiveMember
in interface FileHashLoader
IOException
public long getSize(ProjectFilesystem filesystem, Path path) throws IOException
FileHashLoader
Path
under the given ProjectFilesystem
.getSize
in interface FileHashLoader
IOException
public void set(ProjectFilesystem filesystem, Path path, com.google.common.hash.HashCode hashCode) throws IOException
FileHashCache
set
in interface FileHashCache
IOException
public StackedFileHashCache newDecoratedFileHashCache(java.util.function.Function<ProjectFileHashCache,ProjectFileHashCache> decorateDelegate)
public com.google.common.collect.ImmutableList<? extends ProjectFileHashCache> getCaches()