Package step.repositories.http
Class RepositoryCache<V>
- java.lang.Object
- 
- step.repositories.http.RepositoryCache<V>
 
- 
 public class RepositoryCache<V> extends java.lang.ObjectThis cache associates a unique entry to a defined set of repository's parameters This allows to track resources associated to a run This cache is based on: - An HashMap, that keep in cache the entries currently used by at least one execution - An optional com.google.common.cache.LoadingCache that keep track of the entries currently not used The constructor allows callbacks to create, update or delete the resources and manage the LoadingCache
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description static classRepositoryCache.Entry<V>
 - 
Constructor SummaryConstructors Constructor Description RepositoryCache(java.util.function.Function<java.util.Map<java.lang.String,java.lang.String>,V> createCacheEntry, java.util.function.BiConsumer<java.util.Map<java.lang.String,java.lang.String>,V> updateCacheEntry, java.util.function.Consumer<V> deleteCacheEntry)Simple cacheRepositoryCache(java.util.function.Function<java.util.Map<java.lang.String,java.lang.String>,V> createCacheEntry, java.util.function.BiConsumer<java.util.Map<java.lang.String,java.lang.String>,V> updateCacheEntry, java.util.function.Consumer<V> deleteCacheEntry, com.google.common.cache.CacheBuilder<java.lang.Object,java.lang.Object> cacheBuilder)With external cache for longer term caching
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancontainsKey(java.util.Map<java.lang.String,java.lang.String> repositoryParameter)test if a key is presentRepositoryCache.Entry<V>get(java.util.Map<java.lang.String,java.lang.String> repositoryParameter)RepositoryCache.Entry<V>lock(java.util.Map<java.lang.String,java.lang.String> repositoryParameter)Return the cache entry: - callcreateCacheEntry()if the entry does not exist - callupdateCacheEntry()otherwiseRepositoryCache.Entry<V>release(java.util.Map<java.lang.String,java.lang.String> repositoryParameter)Decrease the corresponding cache entry's usage and put it in the long term cache if needed
 
- 
- 
- 
Constructor Detail- 
RepositoryCachepublic RepositoryCache(java.util.function.Function<java.util.Map<java.lang.String,java.lang.String>,V> createCacheEntry, java.util.function.BiConsumer<java.util.Map<java.lang.String,java.lang.String>,V> updateCacheEntry, java.util.function.Consumer<V> deleteCacheEntry) Simple cacheOnly keep the entries alive in cache during executions, calling deleteCacheEntry() when no execution with this map is running - Parameters:
- createCacheEntry- the function used for creating an entry
- updateCacheEntry- called during a get, to ensure the entry is up to date
- deleteCacheEntry- cleanup the entry and remove the resources
 
 - 
RepositoryCachepublic RepositoryCache(java.util.function.Function<java.util.Map<java.lang.String,java.lang.String>,V> createCacheEntry, java.util.function.BiConsumer<java.util.Map<java.lang.String,java.lang.String>,V> updateCacheEntry, java.util.function.Consumer<V> deleteCacheEntry, com.google.common.cache.CacheBuilder<java.lang.Object,java.lang.Object> cacheBuilder) With external cache for longer term cachingKeep the entry in a cache constructed by the provided builder at the end of all executions related to this cache entry - Parameters:
- createCacheEntry- the function used for creating an entry
- updateCacheEntry- called during a lock, to ensure the entry is up to date
- deleteCacheEntry- cleanup the entry and remove the resources
- cacheBuilder- will be used for caching entries in-between executions
 
 
- 
 - 
Method Detail- 
lockpublic RepositoryCache.Entry<V> lock(java.util.Map<java.lang.String,java.lang.String> repositoryParameter) Return the cache entry: - callcreateCacheEntry()if the entry does not exist - callupdateCacheEntry()otherwiseThe entry will be keep in cache until release()is called- Parameters:
- repositoryParameter- the parameter associated with the entry
- Returns:
- the cache entry
 
 - 
getpublic RepositoryCache.Entry<V> get(java.util.Map<java.lang.String,java.lang.String> repositoryParameter) 
 - 
releasepublic RepositoryCache.Entry<V> release(java.util.Map<java.lang.String,java.lang.String> repositoryParameter) Decrease the corresponding cache entry's usage and put it in the long term cache if needed- Parameters:
- repositoryParameter- : the parameter associated with the entry
- Returns:
- The entry, null if it is not in the cache
 
 - 
containsKeypublic boolean containsKey(java.util.Map<java.lang.String,java.lang.String> repositoryParameter) test if a key is present- Parameters:
- repositoryParameter- the key
- Returns:
- if an entry exists
 
 
- 
 
-