Package com.atlassian.cache
Interface ManagedCache
@Internal
public interface ManagedCache
Interface that managed cache things need to implement
- Since:
- 2.0
-
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Clear the cache.default com.atlassian.instrumentation.caches.CacheCollectorReturns the collector for this cache.getName()The name of the cache, uniquely identifies this cache.Get usage statistics for the cache.booleanReturns true if this cache can be safely flushed any time.booleanisLocal()booleanbooleanbooleanvoidsetStatistics(boolean enabled) Deprecated.booleanupdateExpireAfterAccess(long expireAfter, TimeUnit timeUnit) Attempts to update the hint regarding how long entries that should be held in the cache, after last access.booleanupdateExpireAfterWrite(long expireAfter, TimeUnit timeUnit) Attempts to update the hint regarding how long entries that should be held in the cache, after last write.booleanupdateMaxEntries(int newValue) Attempts to update the hint regarding the maximum number of entries that should be cached at any time.
-
Method Details
-
clear
void clear()Clear the cache. -
getName
The name of the cache, uniquely identifies this cache.- Returns:
- the name of the cache.
-
isFlushable
boolean isFlushable()Returns true if this cache can be safely flushed any time.This method is used by
CacheManager.flushCaches()to only flush caches that can be safely flushed.clear()ignores this value.- Returns:
- true if this cache can be flushed safely.
-
currentMaxEntries
- Returns:
- the current hint regarding the maximum number of entries that should be cached at any time.
nullindicates no current hint
-
updateMaxEntries
boolean updateMaxEntries(int newValue) Attempts to update the hint regarding the maximum number of entries that should be cached at any time.- Parameters:
newValue- the new hint value- Returns:
trueiff the hint has been updated to the new value. If a cache does not support changes at run-time, it must returnfalse
-
currentExpireAfterAccessMillis
- Returns:
- the current hint regarding how long entries should be held in the cache, after last access, measured in
milliseconds.
nullindicates no current hint
-
updateExpireAfterAccess
Attempts to update the hint regarding how long entries that should be held in the cache, after last access.- Parameters:
expireAfter- Time to retain entries for since their last access.timeUnit- TheTimeUnitfor the time- Returns:
trueiff the hint has been updated to the new value. If a cache does not support changes at run-time, it must returnfalse
-
currentExpireAfterWriteMillis
- Returns:
- the current hint regarding how long entries should be held in the cache, after last write, measured in
milliseconds.
nullindicates no current hint
-
updateExpireAfterWrite
Attempts to update the hint regarding how long entries that should be held in the cache, after last write.- Parameters:
expireAfter- Time to retain entries for since their last write.timeUnit- TheTimeUnitfor the time- Returns:
trueiff the hint has been updated to the new value. If a cache does not support changes at run-time, it must returnfalse
-
isLocal
boolean isLocal()- Returns:
- true if the cache is local, and hence is not replicated in a clustered environment
-
isReplicateAsynchronously
boolean isReplicateAsynchronously()- Returns:
- true if this cache should be replicated asynchronously in a clustered environment.
-
isReplicateViaCopy
boolean isReplicateViaCopy()- Returns:
- true if this cache should, in a clustered environment, replicate put and update operations by copying the relevant key and value across the wire (as opposed to just the key).
-
isStatisticsEnabled
boolean isStatisticsEnabled()- Returns:
- true if this cache gathers statistics.
-
setStatistics
Deprecated.UseCacheCollector.setEnabled(boolean)instead for memory caches. This method was never implemented for other cache types.Changes the state of statistics gathering.- Parameters:
enabled- The stats collection is enabled if true - disabled otherwise.- Since:
- 2.8.4
-
getStatistics
Get usage statistics for the cache.The statistics are sorted by the cache statistics key
labels. Providing statistics is an optional feature and no assumptions should be made by the caller about which (if any) statistics will be returned.- Returns:
- a map of statistics keys to suppliers for their values, sorted lexically by the statistics key's label
- Since:
- v2.4.0
-
getCacheCollector
@Nullable default com.atlassian.instrumentation.caches.CacheCollector getCacheCollector()Returns the collector for this cache.- Returns:
- The
CacheCollectorfor this cache. - Since:
- 2.8.4
-
CacheCollector.setEnabled(boolean)instead for memory caches.