com.atlassian.cache
Interface ManagedCache

All Known Implementing Classes:
HazelcastCache, HazelcastCachedReference, HazelcastHybridCache, HazelcastHybridCachedReference, ManagedCacheSupport, ManagedHybridCacheSupport

@Internal
public interface ManagedCache

Interface that managed cache things need to implement

Since:
2.0

Method Summary
 void clear()
          Clear the cache.
 Long currentExpireAfterAccessMillis()
           
 Long currentExpireAfterWriteMillis()
           
 Integer currentMaxEntries()
           
 String getName()
          The name of the cache, uniquely identifies this cache.
 SortedMap<CacheStatisticsKey,com.atlassian.util.concurrent.Supplier<Long>> getStatistics()
          Get usage statistics for the cache.
 boolean isFlushable()
          Returns true if this cache can be safely flushed any time.
 boolean isLocal()
           
 boolean isReplicateAsynchronously()
           
 boolean isReplicateViaCopy()
           
 boolean updateExpireAfterAccess(long expireAfter, TimeUnit timeUnit)
          Attempts to update the hint regarding how long entries that should be held in the cache, after last access.
 boolean updateExpireAfterWrite(long expireAfter, TimeUnit timeUnit)
          Attempts to update the hint regarding how long entries that should be held in the cache, after last write.
 boolean updateMaxEntries(int newValue)
          Attempts to update the hint regarding the maximum number of entries that should be cached at any time.
 

Method Detail

clear

void clear()
Clear the cache.


getName

@Nonnull
String 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

@Nullable
Integer currentMaxEntries()
Returns:
the current hint regarding the maximum number of entries that should be cached at any time. null indicates 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:
true iff the hint has been updated to the new value. If a cache does not support changes at run-time, it must return false

currentExpireAfterAccessMillis

@Nullable
Long currentExpireAfterAccessMillis()
Returns:
the current hint regarding how long entries should be held in the cache, after last access, measured in milliseconds. null indicates no current hint

updateExpireAfterAccess

boolean updateExpireAfterAccess(long expireAfter,
                                @Nonnull
                                TimeUnit timeUnit)
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 - The TimeUnit for the time
Returns:
true iff the hint has been updated to the new value. If a cache does not support changes at run-time, it must return false

currentExpireAfterWriteMillis

@Nullable
Long currentExpireAfterWriteMillis()
Returns:
the current hint regarding how long entries should be held in the cache, after last write, measured in milliseconds. null indicates no current hint

updateExpireAfterWrite

boolean updateExpireAfterWrite(long expireAfter,
                               @Nonnull
                               TimeUnit timeUnit)
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 - The TimeUnit for the time
Returns:
true iff the hint has been updated to the new value. If a cache does not support changes at run-time, it must return false

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).

getStatistics

@Nonnull
SortedMap<CacheStatisticsKey,com.atlassian.util.concurrent.Supplier<Long>> 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


Copyright © 2015 Atlassian. All rights reserved.