Package jetbrains.buildServer.util.cache
Interface SCache<T>
-
public interface SCache<T>
Basic persistent cache support.- Since:
- 6.0
- Author:
- kir
- See Also:
CacheProvider
-
-
Method Summary
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description void
destroy()
Deprecated.since 9.1.1, useinvalidateAll()
method instead.void
dispose()
Flushes data on disk (if cache is persistable) and frees all of the resources associated with this cache.T
fetch(java.lang.String key, Calculator<T> dataFetcher)
Get data from cache, if available.void
flush()
Flush all the cache data to the diskjava.util.Collection<java.lang.String>
getKeys()
java.lang.String
getName()
Name of the cache, as specified upon cache creationvoid
invalidate(java.lang.String key)
Delete cache value for particular keyvoid
invalidateAll()
Invalidates (removes) all cache elementsT
read(java.lang.String key)
Read cache valuevoid
setAllowToReset(boolean allow)
Specify whether it is allowed to reset this cache from UI from the Diagnostic->Caches page.void
write(java.lang.String key, T value)
Put a value to cache with default time to live and time to idlevoid
write(java.lang.String key, T value, int ttlSecs)
Deprecated.since 8.0 please use ttL set for the whole cache instead
-
-
-
Method Detail
-
getName
java.lang.String getName()
Name of the cache, as specified upon cache creation
-
write
void write(@NotNull java.lang.String key, @Nullable T value)
Put a value to cache with default time to live and time to idle- Parameters:
key
- cache keyvalue
- serializable value. If null, cached value is removed
-
write
@Deprecated void write(@NotNull java.lang.String key, @Nullable T value, int ttlSecs)
Deprecated.since 8.0 please use ttL set for the whole cache insteadPut a value to cache with timeout (time to live)- Parameters:
key
- cache keyvalue
- serializable value. If null, cached value is removedttlSecs
- Time to live for cached value in seconds. 0 means no TTL (eternal)
-
read
@Nullable T read(@NotNull java.lang.String key)
Read cache value
-
getKeys
@NotNull java.util.Collection<java.lang.String> getKeys()
- Returns:
- keys for values stored in cache
-
fetch
T fetch(java.lang.String key, Calculator<T> dataFetcher)
Get data from cache, if available. If not, obtain the data using dataFetcher and put them to the cache. The operation is blocking for a particular key. I.e. multiple fetch operations for a single key will wait until first of them will fill the cache.- Parameters:
key
- cache keydataFetcher
- a procedure to obtain data if it is not found in the cache (data is put to the cache in this case)- Returns:
- data from cache or from the dataFetcher
-
invalidate
void invalidate(@NotNull java.lang.String key)
Delete cache value for particular key
-
invalidateAll
void invalidateAll()
Invalidates (removes) all cache elements- Since:
- 9.1.1
-
flush
void flush()
Flush all the cache data to the disk
-
destroy
void destroy()
Deprecated.since 9.1.1, useinvalidateAll()
method instead.Same asinvalidateAll()
.
-
setAllowToReset
void setAllowToReset(boolean allow)
Specify whether it is allowed to reset this cache from UI from the Diagnostic->Caches page.- Since:
- 8.0
-
dispose
void dispose()
Flushes data on disk (if cache is persistable) and frees all of the resources associated with this cache.
-
-