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
 void destroy()
          Destroy all cache elements for 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 disk
 java.lang.String getName()
          Name of the cache, as specified upon cache creation
 void invalidate(java.lang.String key)
          Delete cache value for particular key
 T read(java.lang.String key)
          Read cache value
 void 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 without timeout
 void 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 without timeout

Parameters:
key - cache key
value - serializable value. If null, cached value is removed

write

void write(@NotNull
           java.lang.String key,
           @Nullable
           T value,
           int ttlSecs)
Deprecated. since 8.0 please use ttL set for the whole cache instead

Put a value to cache with timeout (time to live)

Parameters:
key - cache key
value - serializable value. If null, cached value is removed
ttlSecs - 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


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 key
dataFetcher - a procegure 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


flush

void flush()
Flush all the cache data to the disk


destroy

void destroy()
Destroy all cache elements for this cache


setAllowToReset

void setAllowToReset(boolean allow)
Specify whether it is allowed to reset this cache from UI from the Diagnostic->Caches page.

Since:
8.0