Class HttpCacheImpl
- java.lang.Object
-
- jetbrains.buildServer.artifacts.impl.HttpCacheImpl
-
- All Implemented Interfaces:
FileCache
,LocalCache
public class HttpCacheImpl extends Object implements FileCache
Author: Nikita.Skvortsov Date: 2/22/11
-
-
Constructor Summary
Constructors Constructor Description HttpCacheImpl(HttpDiskCache diskCache, URLContentRetriever transport)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
cleanUpCache()
Cleanup cache: delete outdated items according to current cache optionsvoid
cleanUpCache(long itemLifeTimeMillis)
Delete items from cache whose life time in cache is greater than specified valuevoid
cleanUpCache(long curMaxLifeTimeMs, Condition<Void> isInterrupted)
Delete items from cache whose life time in cache is greater than specified value Allows to interrupt.void
delete(String key)
Delete cache entry.File
getCachedFile(String key, String expectedDigest)
CacheOptions
getCacheOptions()
Get cache optionsFile
getFile(String key)
Get cached file.boolean
isValid(String key)
Check if file under given key, is valid.Collection<File>
listCache()
List cache content.void
putFile(String key, File file)
Put file into cache under given key.void
putFile(String key, File file, String digest)
Put file into cache under given key with given digest.void
putFiles(Map<String,File> keyToFileMap, Map<File,String> fileToDigestMap)
Put files into cache under given keys.
-
-
-
Constructor Detail
-
HttpCacheImpl
public HttpCacheImpl(@NotNull HttpDiskCache diskCache, @NotNull URLContentRetriever transport)
-
-
Method Detail
-
isValid
public boolean isValid(String key)
Description copied from interface:FileCache
Check if file under given key, is valid.
-
getFile
@NotNull public File getFile(@NotNull String key) throws IOException
Description copied from interface:FileCache
Get cached file. Ensures file is in cache directory and is valid. Updates file, if necessary.- Specified by:
getFile
in interfaceFileCache
- Parameters:
key
- key for file.- Returns:
- file in cache directory
- Throws:
IOException
- if error occures.
-
putFile
public void putFile(@NotNull String key, @NotNull File file) throws IOException
Description copied from interface:LocalCache
Put file into cache under given key.- Specified by:
putFile
in interfaceLocalCache
- Throws:
IOException
-
putFile
public void putFile(@NotNull String key, @NotNull File file, @Nullable String digest) throws IOException
Description copied from interface:LocalCache
Put file into cache under given key with given digest.- Specified by:
putFile
in interfaceLocalCache
- Throws:
IOException
-
putFiles
public void putFiles(@NotNull Map<String,File> keyToFileMap, @NotNull Map<File,String> fileToDigestMap) throws IOException
Description copied from interface:LocalCache
Put files into cache under given keys.- Specified by:
putFiles
in interfaceLocalCache
- Parameters:
keyToFileMap
- mapping of keys to filesfileToDigestMap
- mapping of files to file digests- Throws:
IOException
-
getCachedFile
@Nullable public File getCachedFile(@NotNull String key, @NotNull String expectedDigest)
- Specified by:
getCachedFile
in interfaceLocalCache
- Returns:
- cached file for specified key if the file exists and is valid, otherwise null
-
delete
public void delete(@NotNull String key)
Description copied from interface:LocalCache
Delete cache entry. Deletes cache entry and underlying content file.- Specified by:
delete
in interfaceLocalCache
- Parameters:
key
- key to delete
-
listCache
@NotNull public Collection<File> listCache()
Description copied from interface:LocalCache
List cache content.- Specified by:
listCache
in interfaceLocalCache
- Returns:
- collection of all files on disk in cache
-
getCacheOptions
@NotNull public CacheOptions getCacheOptions()
Description copied from interface:LocalCache
Get cache options- Specified by:
getCacheOptions
in interfaceLocalCache
- Returns:
- current cache options
-
cleanUpCache
public void cleanUpCache(long curMaxLifeTimeMs, Condition<Void> isInterrupted)
Description copied from interface:LocalCache
Delete items from cache whose life time in cache is greater than specified value Allows to interrupt.- Specified by:
cleanUpCache
in interfaceLocalCache
isInterrupted
- predicate to check for interrupt
-
cleanUpCache
public void cleanUpCache(long itemLifeTimeMillis)
Description copied from interface:LocalCache
Delete items from cache whose life time in cache is greater than specified value- Specified by:
cleanUpCache
in interfaceLocalCache
-
cleanUpCache
public void cleanUpCache()
Description copied from interface:LocalCache
Cleanup cache: delete outdated items according to current cache options- Specified by:
cleanUpCache
in interfaceLocalCache
-
-