Class HazelcastHybridCache<K,V>
- All Implemented Interfaces:
com.atlassian.cache.Cache<K,,V> com.atlassian.cache.ManagedCache,com.atlassian.cache.ReadThroughCache<K,V>
ManagedCache and Cache that can be used when the cached values do not implement
Serializable but cache invalidation must work cluster-wide.
This implementation tracks versions of entries in Hazelcast IMap, but stores the actual values in a local
cache. Caches entries are invalidated when the cache is modified through one of the put, clear,
remove or replace methods. Cache entries are never invalidated when get(Object) is called,
not even when a value is lazily created and added to the cache.
These semantics mean that hybrid caches should only be used as computing caches (by providing a CacheLoader) and that values should not be manually put(Object, Object) in the cache.
Doing so will lead to frequent cache evictions.
- Since:
- 2.4.0
-
Field Summary
Fields inherited from class com.atlassian.cache.hazelcast.ManagedHybridCacheSupport
cacheManager, name -
Constructor Summary
ConstructorsConstructorDescriptionHazelcastHybridCache(String name, com.atlassian.cache.CacheFactory localCacheFactory, com.hazelcast.map.IMap<K, Long> versionMap, com.atlassian.cache.CacheLoader<K, V> cacheLoader, HazelcastCacheManager cacheManager) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddListener(com.atlassian.cache.CacheEntryListener<K, V> listener, boolean includeValues) voidclear()booleancontainsKey(K k) getKeys()protected com.atlassian.cache.ManagedCachegetName()booleanbooleanvoidputIfAbsent(K key, V value) voidbooleanvoidvoidremoveListener(com.atlassian.cache.CacheEntryListener<K, V> listener) booleanbooleanupdateExpireAfterAccess(long expireAfter, TimeUnit timeUnit) booleanupdateExpireAfterWrite(long expireAfter, TimeUnit timeUnit) booleanupdateMaxEntries(int newValue) Methods inherited from class com.atlassian.cache.hazelcast.ManagedHybridCacheSupport
currentExpireAfterAccessMillis, currentExpireAfterWriteMillis, currentMaxEntries, getStatistics, isLocal, isReplicateViaCopy, isStatisticsEnabled, setStatisticsMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.atlassian.cache.ManagedCache
getCacheCollectorMethods inherited from interface com.atlassian.cache.ReadThroughCache
getBulk
-
Constructor Details
-
HazelcastHybridCache
-
-
Method Details
-
clear
public void clear()- Specified by:
clearin interfacecom.atlassian.cache.ManagedCache
-
containsKey
-
get
-
get
-
getKeys
-
getName
- Specified by:
getNamein interfacecom.atlassian.cache.ManagedCache- Specified by:
getNamein interfacecom.atlassian.cache.ReadThroughCache<K,V> - Overrides:
getNamein classManagedHybridCacheSupport
-
isReplicateAsynchronously
public boolean isReplicateAsynchronously()- Specified by:
isReplicateAsynchronouslyin interfacecom.atlassian.cache.ManagedCache
-
put
-
putIfAbsent
This implementation has a weak spot: When there is an existing value, this method must return it. However, if that value is stored in a remote node, it cannot be returned.
nullis returned instead, which signals success. In order to not break any contracts, this implementation will invalidate the value on all nodes in this situation. -
remove
-
remove
-
removeAll
public void removeAll() -
replace
-
updateExpireAfterAccess
- Specified by:
updateExpireAfterAccessin interfacecom.atlassian.cache.ManagedCache- Overrides:
updateExpireAfterAccessin classManagedHybridCacheSupport
-
updateExpireAfterWrite
- Specified by:
updateExpireAfterWritein interfacecom.atlassian.cache.ManagedCache- Overrides:
updateExpireAfterWritein classManagedHybridCacheSupport
-
updateMaxEntries
public boolean updateMaxEntries(int newValue) - Specified by:
updateMaxEntriesin interfacecom.atlassian.cache.ManagedCache- Overrides:
updateMaxEntriesin classManagedHybridCacheSupport
-
addListener
-
removeListener
-
getLocalCache
protected com.atlassian.cache.ManagedCache getLocalCache()- Specified by:
getLocalCachein classManagedHybridCacheSupport
-
isFlushable
public boolean isFlushable()- Specified by:
isFlushablein interfacecom.atlassian.cache.ManagedCache
-