Package com.facebook.buck.artifact_cache
Interface ArtifactCache
-
- All Superinterfaces:
AutoCloseable
- All Known Implementing Classes:
AbstractAsynchronousCache
,AbstractNetworkCache
,DirArtifactCache
,HttpArtifactCache
,LoggingArtifactCacheDecorator
,MultiArtifactCache
,NoopArtifactCache
,RetryingCacheDecorator
,SQLiteArtifactCache
,ThriftArtifactCache
,TwoLevelArtifactCacheDecorator
public interface ArtifactCache extends AutoCloseable
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description void
close()
com.google.common.util.concurrent.ListenableFuture<CacheDeleteResult>
deleteAsync(List<RuleKey> ruleKeys)
com.google.common.util.concurrent.ListenableFuture<CacheResult>
fetchAsync(BuildTarget target, RuleKey ruleKey, LazyPath output)
Fetch a cached artifact, keyed by ruleKey, save the artifact to path specified by output, and return true on success.CacheReadMode
getCacheReadMode()
This method must return the same value over the lifetime of this object.com.google.common.util.concurrent.ListenableFuture<com.google.common.collect.ImmutableMap<RuleKey,CacheResult>>
multiContainsAsync(com.google.common.collect.ImmutableSet<RuleKey> ruleKeys)
Check if the cache contains the given artifacts, keyed by ruleKeys, without fetching them, and return a map of results wrapped in aListenableFuture
.void
skipPendingAndFutureAsyncFetches()
All pending (and future) async fetches will be immediately marked as skipped.com.google.common.util.concurrent.ListenableFuture<Unit>
store(ArtifactInfo info, BorrowablePath output)
Store the artifact at path specified by output to cache, such that it can later be fetched using ruleKey as the lookup key.default com.google.common.util.concurrent.ListenableFuture<Unit>
store(com.google.common.collect.ImmutableList<Pair<ArtifactInfo,BorrowablePath>> artifacts)
Store the list of artifacts at path specified by output to cache in passed order, such that it can later be fetched using ruleKey as the lookup key.
-
-
-
Method Detail
-
fetchAsync
com.google.common.util.concurrent.ListenableFuture<CacheResult> fetchAsync(@Nullable BuildTarget target, RuleKey ruleKey, LazyPath output)
Fetch a cached artifact, keyed by ruleKey, save the artifact to path specified by output, and return true on success.- Parameters:
target
- rule for which this is an artifactruleKey
- cache fetch keyoutput
- Path to store artifact to. Path should not be accessed unless store operation is guaranteed by the cache, to avoid potential extra disk I/O.- Returns:
- whether it was a
CacheResultType.MISS
(indicating a failure) or some type of hit.
-
skipPendingAndFutureAsyncFetches
void skipPendingAndFutureAsyncFetches()
All pending (and future) async fetches will be immediately marked as skipped.
-
store
com.google.common.util.concurrent.ListenableFuture<Unit> store(ArtifactInfo info, BorrowablePath output)
Store the artifact at path specified by output to cache, such that it can later be fetched using ruleKey as the lookup key. If any internal errors occur, fail silently and continue execution. Store may be performed synchronously or asynchronously.This is a noop if
getCacheReadMode()
} returnsREADONLY
.- Parameters:
info
- information to store with the artifactoutput
- path to read artifact from. If its borrowable, you may freely move the file into cache without obtaining a copy of the file.- Returns:
ListenableFuture
that completes once the store has finished.
-
store
default com.google.common.util.concurrent.ListenableFuture<Unit> store(com.google.common.collect.ImmutableList<Pair<ArtifactInfo,BorrowablePath>> artifacts)
Store the list of artifacts at path specified by output to cache in passed order, such that it can later be fetched using ruleKey as the lookup key. If any internal errors occur, fail silently and continue execution. Store may be performed synchronously or asynchronously.This is a noop if
getCacheReadMode()
} returnsREADONLY
.- Parameters:
artifacts
- list of artifact info and path to be uploaded to the cache in given order.- Returns:
ListenableFuture
that completes once the store has finished.
-
multiContainsAsync
com.google.common.util.concurrent.ListenableFuture<com.google.common.collect.ImmutableMap<RuleKey,CacheResult>> multiContainsAsync(com.google.common.collect.ImmutableSet<RuleKey> ruleKeys)
Check if the cache contains the given artifacts, keyed by ruleKeys, without fetching them, and return a map of results wrapped in aListenableFuture
. This is supposed to be fast, but best-effort, meaning that there will be false-positives.- Parameters:
ruleKeys
- Set of cache fetch keys.- Returns:
- map of keys to
CacheResult
which can be aCacheResultType.MISS
/CacheResultType.ERROR
(indicating a failure) orCacheResultType.CONTAINS
.
-
deleteAsync
com.google.common.util.concurrent.ListenableFuture<CacheDeleteResult> deleteAsync(List<RuleKey> ruleKeys)
-
getCacheReadMode
CacheReadMode getCacheReadMode()
This method must return the same value over the lifetime of this object.- Returns:
- whether this
ArtifactCache
supports storing artifacts.
-
close
void close()
- Specified by:
close
in interfaceAutoCloseable
-
-