Class HazelcastAsyncHybridCache<K,V>

java.lang.Object
com.atlassian.cache.hazelcast.ManagedHybridCacheSupport
com.atlassian.cache.hazelcast.HazelcastAsyncHybridCache<K,V>
All Implemented Interfaces:
com.atlassian.cache.Cache<K,V>, com.atlassian.cache.ManagedCache, com.atlassian.cache.ReadThroughCache<K,V>

public class HazelcastAsyncHybridCache<K,V> extends ManagedHybridCacheSupport implements com.atlassian.cache.Cache<K,V>
Implementation of ManagedCache and Cache that does not require the values to be Serializable. It works by caching values locally and broadcasting invalidations cluster-wide using a Hazelcast ITopic.

Cache entries are invalidated when the cache is modified through one of the methods clear(), remove(K), replace(K, V, V), or put(K, V) (when it overwrites an existing value).

Since:
2.12.0
  • Constructor Details

    • HazelcastAsyncHybridCache

      public HazelcastAsyncHybridCache(String name, com.atlassian.cache.CacheFactory localCacheFactory, com.hazelcast.topic.ITopic<com.atlassian.cache.hazelcast.HazelcastAsyncHybridCache.Invalidate> invalidationTopic, com.atlassian.cache.CacheLoader<K,V> cacheLoader, HazelcastCacheManager cacheManager, com.atlassian.cache.CacheSettings settings)
  • Method Details

    • clear

      public void clear()
      Specified by:
      clear in interface com.atlassian.cache.ManagedCache
    • containsKey

      public boolean containsKey(@Nonnull K key)
      Specified by:
      containsKey in interface com.atlassian.cache.ReadThroughCache<K,V>
    • get

      public V get(@Nonnull K key)
      Specified by:
      get in interface com.atlassian.cache.ReadThroughCache<K,V>
    • get

      @Nonnull public V get(@Nonnull K key, @Nonnull com.atlassian.cache.Supplier<? extends V> valueSupplier)
      Specified by:
      get in interface com.atlassian.cache.ReadThroughCache<K,V>
    • getBulk

      @Nonnull public Map<K,V> getBulk(@Nonnull Set<K> keys, @Nonnull Function<Set<K>,Map<K,V>> valuesSupplier)
      Provide an overriden implementation of ReadThroughCache.getBulk(Set, Function) that just delegates to the local cache. This prevents calls to put(Object, Object) from the default implementation triggering unwanted invalidations.
      Specified by:
      getBulk in interface com.atlassian.cache.ReadThroughCache<K,V>
    • getKeys

      @Nonnull public Collection<K> getKeys()
      Specified by:
      getKeys in interface com.atlassian.cache.ReadThroughCache<K,V>
    • getName

      @Nonnull public String getName()
      Specified by:
      getName in interface com.atlassian.cache.ManagedCache
      Specified by:
      getName in interface com.atlassian.cache.ReadThroughCache<K,V>
      Overrides:
      getName in class ManagedHybridCacheSupport
    • isFlushable

      public boolean isFlushable()
      Specified by:
      isFlushable in interface com.atlassian.cache.ManagedCache
    • isReplicateAsynchronously

      public boolean isReplicateAsynchronously()
      Specified by:
      isReplicateAsynchronously in interface com.atlassian.cache.ManagedCache
    • put

      public void put(@Nonnull K key, @Nonnull V value)
      Specified by:
      put in interface com.atlassian.cache.Cache<K,V>
    • putIfAbsent

      public V putIfAbsent(@Nonnull K key, @Nonnull V value)
      Specified by:
      putIfAbsent in interface com.atlassian.cache.Cache<K,V>
    • remove

      public void remove(@Nonnull K key)
      Specified by:
      remove in interface com.atlassian.cache.ReadThroughCache<K,V>
    • remove

      public boolean remove(@Nonnull K key, @Nonnull V value)
      Specified by:
      remove in interface com.atlassian.cache.ReadThroughCache<K,V>
    • removeAll

      public void removeAll()
      Specified by:
      removeAll in interface com.atlassian.cache.ReadThroughCache<K,V>
    • replace

      public boolean replace(@Nonnull K key, @Nonnull V oldValue, @Nonnull V newValue)
      Specified by:
      replace in interface com.atlassian.cache.Cache<K,V>
    • addListener

      public void addListener(@Nonnull com.atlassian.cache.CacheEntryListener<K,V> listener, boolean includeValues)
      Specified by:
      addListener in interface com.atlassian.cache.Cache<K,V>
    • removeListener

      public void removeListener(@Nonnull com.atlassian.cache.CacheEntryListener<K,V> listener)
      Specified by:
      removeListener in interface com.atlassian.cache.Cache<K,V>
    • getLocalCache

      protected com.atlassian.cache.ManagedCache getLocalCache()
      Specified by:
      getLocalCache in class ManagedHybridCacheSupport