java.io.Closeable
, java.lang.AutoCloseable
, BuildCache
@Incubating public class MapBasedBuildCache extends java.lang.Object implements BuildCache
ConcurrentMap
.Constructor | Description |
---|---|
MapBasedBuildCache(java.lang.String description,
java.util.concurrent.ConcurrentMap<java.lang.String,byte[]> delegate) |
Modifier and Type | Method | Description |
---|---|---|
void |
close() |
Clean up any resources held by the cache once it's not used anymore.
|
java.lang.String |
getDescription() |
Returns a description for the cache.
|
boolean |
load(BuildCacheKey key,
BuildCacheEntryReader reader) |
Load the cached entry corresponding to the given cache key.
|
void |
store(BuildCacheKey key,
BuildCacheEntryWriter output) |
Store the cache entry with the given cache key.
|
public MapBasedBuildCache(java.lang.String description, java.util.concurrent.ConcurrentMap<java.lang.String,byte[]> delegate)
public java.lang.String getDescription()
BuildCache
getDescription
in interface BuildCache
public boolean load(BuildCacheKey key, BuildCacheEntryReader reader) throws BuildCacheException
BuildCache
reader
will be called if an entry is found in the cache.load
in interface BuildCache
key
- the cache key.reader
- the reader to read the data corresponding to the cache key.true
if an entry was found, false
otherwise.BuildCacheException
- if the cache fails to load a cache entry for the given keypublic void store(BuildCacheKey key, BuildCacheEntryWriter output) throws BuildCacheException
BuildCache
writer
will be called to actually write the data.store
in interface BuildCache
key
- the cache key.output
- the writer to write the data corresponding to the cache key.BuildCacheException
- if the cache fails to store a cache entry for the given keypublic void close() throws java.io.IOException
BuildCache
close
in interface java.lang.AutoCloseable
close
in interface BuildCache
close
in interface java.io.Closeable
java.io.IOException
- if the cache fails to close cleanly.