com.atlassian.confluence.cache.hazelcast.hybrid
Class ConfluenceHybridCache<K,V>
java.lang.Object
com.atlassian.confluence.cache.hazelcast.AbstractHazelcastCache<K,V>
com.atlassian.confluence.cache.hazelcast.hybrid.ConfluenceHybridCache<K,V>
- All Implemented Interfaces:
- com.atlassian.cache.Cache<K,V>, com.atlassian.cache.ManagedCache, ConfigurableCache<K,V>, ConfigurableManagedLockingCache<K,V>, ManagedLockingCache<K,V>
public class ConfluenceHybridCache<K,V>
- extends AbstractHazelcastCache<K,V>
Implementation of ConfigurableCache
and ManagedCache
that can be used when the cached values do not implement Serializable but
cache invalidation must work cluster-wide.
This implementation keeps count of entries in Hazelcast IMap
, but stores the actual values in a local cache.
Constructor Summary |
ConfluenceHybridCache(java.lang.String cacheName,
com.hazelcast.core.IMap<K,java.lang.Long> hazelcastMap,
com.hazelcast.config.MapConfig hazelcastMapConfig,
com.atlassian.cache.CacheFactory localCacheFactory,
com.atlassian.cache.CacheLoader<K,V> cacheLoader,
com.atlassian.cache.CacheSettings settings,
boolean flushable)
|
Method Summary |
void |
clear()
|
boolean |
containsKey(K k)
|
V |
get(K key)
|
java.util.Collection<K> |
getKeys()
|
boolean |
isReplicateViaCopy()
|
void |
lock(K key,
org.joda.time.Duration leaseTime)
|
void |
put(K key,
V value)
|
V |
putIfAbsent(K key,
V value)
This implementation has a weak spot: When there is an existing value, this method must return it. |
void |
remove(K key)
|
boolean |
remove(K key,
V value)
|
void |
removeAll()
|
boolean |
replace(K key,
V oldValue,
V newValue)
|
void |
setTimeToLive(long timeToLive,
java.util.concurrent.TimeUnit timeUnit)
Deprecated. |
void |
unlock(K key)
|
boolean |
updateExpireAfterAccess(long expireAfter,
java.util.concurrent.TimeUnit timeUnit)
|
boolean |
updateExpireAfterWrite(long expireAfter,
java.util.concurrent.TimeUnit timeUnit)
|
boolean |
updateMaxEntries(int newValue)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ConfluenceHybridCache
public ConfluenceHybridCache(java.lang.String cacheName,
com.hazelcast.core.IMap<K,java.lang.Long> hazelcastMap,
com.hazelcast.config.MapConfig hazelcastMapConfig,
com.atlassian.cache.CacheFactory localCacheFactory,
com.atlassian.cache.CacheLoader<K,V> cacheLoader,
com.atlassian.cache.CacheSettings settings,
boolean flushable)
get
public V get(K key)
containsKey
public boolean containsKey(@NotNull
K k)
getKeys
public java.util.Collection<K> getKeys()
put
public void put(K key,
V value)
remove
public void remove(K key)
removeAll
public void removeAll()
putIfAbsent
public V putIfAbsent(K key,
V value)
-
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. null is returned instead, which signals
success. In order to not break any contracts, this implementation will invalidate the value on all nodes in this
situation.
replace
public boolean replace(K key,
V oldValue,
V newValue)
remove
public boolean remove(K key,
V value)
clear
public void clear()
updateMaxEntries
public boolean updateMaxEntries(int newValue)
- Specified by:
updateMaxEntries
in interface com.atlassian.cache.ManagedCache
- Overrides:
updateMaxEntries
in class AbstractHazelcastCache<K,V>
updateExpireAfterAccess
public boolean updateExpireAfterAccess(long expireAfter,
java.util.concurrent.TimeUnit timeUnit)
- Specified by:
updateExpireAfterAccess
in interface com.atlassian.cache.ManagedCache
- Overrides:
updateExpireAfterAccess
in class AbstractHazelcastCache<K,V>
updateExpireAfterWrite
public boolean updateExpireAfterWrite(long expireAfter,
java.util.concurrent.TimeUnit timeUnit)
- Specified by:
updateExpireAfterWrite
in interface com.atlassian.cache.ManagedCache
- Overrides:
updateExpireAfterWrite
in class AbstractHazelcastCache<K,V>
isReplicateViaCopy
public boolean isReplicateViaCopy()
setTimeToLive
@Deprecated
public void setTimeToLive(long timeToLive,
java.util.concurrent.TimeUnit timeUnit)
- Deprecated.
- Description copied from interface:
ConfigurableCache
- Update the time to live. Please note, some implementations cannot store time values smaller than
TimeUnit.SECONDS
.
- Specified by:
setTimeToLive
in interface ConfigurableCache<K,V>
- Overrides:
setTimeToLive
in class AbstractHazelcastCache<K,V>
- Parameters:
timeToLive
- valuetimeUnit
- unit of time
lock
public void lock(K key,
org.joda.time.Duration leaseTime)
unlock
public void unlock(K key)
Copyright © 2003-2014 Atlassian. All Rights Reserved.