com.atlassian.cache.hazelcast
Class ManagedCacheSupport

java.lang.Object
  extended by com.atlassian.cache.hazelcast.ManagedCacheSupport
All Implemented Interfaces:
ManagedCache
Direct Known Subclasses:
HazelcastCache, HazelcastCachedReference

public abstract class ManagedCacheSupport
extends Object
implements ManagedCache

Hazelcast implementation of common ManagedCache contract


Constructor Summary
ManagedCacheSupport(String name, com.hazelcast.config.MapConfig config, CacheSettings settings)
           
 
Method Summary
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.atlassian.cache.ManagedCache
clear
 

Constructor Detail

ManagedCacheSupport

public ManagedCacheSupport(String name,
                           com.hazelcast.config.MapConfig config,
                           CacheSettings settings)
Method Detail

currentExpireAfterAccessMillis

@Nullable
public Long currentExpireAfterAccessMillis()
Specified by:
currentExpireAfterAccessMillis in interface ManagedCache
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

currentExpireAfterWriteMillis

@Nullable
public Long currentExpireAfterWriteMillis()
Specified by:
currentExpireAfterWriteMillis in interface ManagedCache
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

currentMaxEntries

@Nullable
public Integer currentMaxEntries()
Specified by:
currentMaxEntries in interface ManagedCache
Returns:
the current hint regarding the maximum number of entries that should be cached at any time. null indicates no current hint

isReplicateViaCopy

public boolean isReplicateViaCopy()
Specified by:
isReplicateViaCopy in interface ManagedCache
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).

getName

@Nonnull
public String getName()
Description copied from interface: ManagedCache
The name of the cache, uniquely identifies this cache.

Specified by:
getName in interface ManagedCache
Returns:
the name of the cache.

isFlushable

public boolean isFlushable()
Description copied from interface: ManagedCache
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. ManagedCache.clear() ignores this value.

Specified by:
isFlushable in interface ManagedCache
Returns:
true if this cache can be flushed safely.

isLocal

public boolean isLocal()
Specified by:
isLocal in interface ManagedCache
Returns:
true if the cache is local, and hence is not replicated in a clustered environment

isReplicateAsynchronously

public boolean isReplicateAsynchronously()
Specified by:
isReplicateAsynchronously in interface ManagedCache
Returns:
true if this cache should be replicated asynchronously in a clustered environment.

updateExpireAfterAccess

public boolean updateExpireAfterAccess(long expireAfter,
                                       @Nonnull
                                       TimeUnit timeUnit)
Description copied from interface: ManagedCache
Attempts to update the hint regarding how long entries that should be held in the cache, after last access.

Specified by:
updateExpireAfterAccess in interface ManagedCache
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

updateExpireAfterWrite

public boolean updateExpireAfterWrite(long expireAfter,
                                      @Nonnull
                                      TimeUnit timeUnit)
Description copied from interface: ManagedCache
Attempts to update the hint regarding how long entries that should be held in the cache, after last write.

Specified by:
updateExpireAfterWrite in interface ManagedCache
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

updateMaxEntries

public boolean updateMaxEntries(int newValue)
Description copied from interface: ManagedCache
Attempts to update the hint regarding the maximum number of entries that should be cached at any time.

Specified by:
updateMaxEntries in interface ManagedCache
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

getStatistics

@Nonnull
public SortedMap<CacheStatisticsKey,com.atlassian.util.concurrent.Supplier<Long>> getStatistics()
Description copied from interface: ManagedCache
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.

Specified by:
getStatistics in interface ManagedCache
Returns:
a map of statistics keys to suppliers for their values, sorted lexically by the statistics key's label


Copyright © 2015 Atlassian. All rights reserved.