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 voidcleanUpCache()Cleanup cache: delete outdated items according to current cache optionsvoidcleanUpCache(long itemLifeTimeMillis)Delete items from cache whose life time in cache is greater than specified valuevoidcleanUpCache(long curMaxLifeTimeMs, Condition<Void> isInterrupted)Delete items from cache whose life time in cache is greater than specified value Allows to interrupt.voiddelete(String key)Delete cache entry.FilegetCachedFile(String key, String expectedDigest)CacheOptionsgetCacheOptions()Get cache optionsFilegetFile(String key)Get cached file.booleanisValid(String key)Check if file under given key, is valid.Collection<File>listCache()List cache content.voidputFile(String key, File file)Put file into cache under given key.voidputFile(String key, File file, String digest)Put file into cache under given key with given digest.voidputFiles(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:FileCacheCheck if file under given key, is valid.
-
getFile
@NotNull public File getFile(@NotNull String key) throws IOException
Description copied from interface:FileCacheGet cached file. Ensures file is in cache directory and is valid. Updates file, if necessary.- Specified by:
getFilein 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 IOExceptionDescription copied from interface:LocalCachePut file into cache under given key.- Specified by:
putFilein interfaceLocalCache- Throws:
IOException
-
putFile
public void putFile(@NotNull String key, @NotNull File file, @Nullable String digest) throws IOExceptionDescription copied from interface:LocalCachePut file into cache under given key with given digest.- Specified by:
putFilein interfaceLocalCache- Throws:
IOException
-
putFiles
public void putFiles(@NotNull Map<String,File> keyToFileMap, @NotNull Map<File,String> fileToDigestMap) throws IOExceptionDescription copied from interface:LocalCachePut files into cache under given keys.- Specified by:
putFilesin 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:
getCachedFilein 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:LocalCacheDelete cache entry. Deletes cache entry and underlying content file.- Specified by:
deletein interfaceLocalCache- Parameters:
key- key to delete
-
listCache
@NotNull public Collection<File> listCache()
Description copied from interface:LocalCacheList cache content.- Specified by:
listCachein interfaceLocalCache- Returns:
- collection of all files on disk in cache
-
getCacheOptions
@NotNull public CacheOptions getCacheOptions()
Description copied from interface:LocalCacheGet cache options- Specified by:
getCacheOptionsin interfaceLocalCache- Returns:
- current cache options
-
cleanUpCache
public void cleanUpCache(long curMaxLifeTimeMs, Condition<Void> isInterrupted)Description copied from interface:LocalCacheDelete items from cache whose life time in cache is greater than specified value Allows to interrupt.- Specified by:
cleanUpCachein interfaceLocalCacheisInterrupted- predicate to check for interrupt
-
cleanUpCache
public void cleanUpCache(long itemLifeTimeMillis)
Description copied from interface:LocalCacheDelete items from cache whose life time in cache is greater than specified value- Specified by:
cleanUpCachein interfaceLocalCache
-
cleanUpCache
public void cleanUpCache()
Description copied from interface:LocalCacheCleanup cache: delete outdated items according to current cache options- Specified by:
cleanUpCachein interfaceLocalCache
-
-