Class HibernateClusterAwareCacheManager
- java.lang.Object
-
- com.atlassian.confluence.impl.cache.hibernate.HibernateClusterAwareCacheManager
-
- All Implemented Interfaces:
com.atlassian.cache.CacheFactory,com.atlassian.cache.CacheManager,org.springframework.beans.factory.InitializingBean
@Internal public class HibernateClusterAwareCacheManager extends Object implements com.atlassian.cache.CacheManager, org.springframework.beans.factory.InitializingBean
Make sure Hibernate L2 caches are flushed correctly in Data Center. In Data Center, Hibernate L2 caches are backed by Hazelcast and are divided into multiple regions. By default, all these regions are stored as distributed IMaps except for query cache region which is stored locally on each node thus not managed byCacheManager. Due to how query caching works in Hibernate, query caches *must* always be flushed whenever timestamp caches are flushed. This class publishes a cluster event to flush query caches on *each* node when timestamp caches are flushed viaCacheManager- Since:
- 6.14
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidafterPropertiesSet()voidflushCaches()<K,V>
@NonNull com.atlassian.cache.Cache<K,V>getCache(@NonNull Class<?> owningClass, @NonNull String name)<K,V>
@NonNull com.atlassian.cache.Cache<K,V>getCache(@NonNull String name)<K,V>
@NonNull com.atlassian.cache.Cache<K,V>getCache(@NonNull String name, @NonNull Class<K> keyType, @NonNull Class<V> valueType)<K,V>
@NonNull com.atlassian.cache.Cache<K,V>getCache(@NonNull String name, @Nullable com.atlassian.cache.CacheLoader<K,V> loader)<K,V>
@NonNull com.atlassian.cache.Cache<K,V>getCache(@NonNull String name, @Nullable com.atlassian.cache.CacheLoader<K,V> loader, @NonNull com.atlassian.cache.CacheSettings required)<V> @NonNull com.atlassian.cache.CachedReference<V>getCachedReference(@NonNull Class<?> owningClass, @NonNull String name, @NonNull com.atlassian.cache.Supplier<V> supplier)<V> @NonNull com.atlassian.cache.CachedReference<V>getCachedReference(@NonNull Class<?> owningClass, @NonNull String name, @NonNull com.atlassian.cache.Supplier<V> supplier, @NonNull com.atlassian.cache.CacheSettings required)<V> @NonNull com.atlassian.cache.CachedReference<V>getCachedReference(@NonNull String name, @NonNull com.atlassian.cache.Supplier<V> supplier)<V> @NonNull com.atlassian.cache.CachedReference<V>getCachedReference(@NonNull String name, @NonNull com.atlassian.cache.Supplier<V> supplier, @NonNull com.atlassian.cache.CacheSettings required)@NonNull Collection<com.atlassian.cache.Cache<?,?>>getCaches()@Nullable com.atlassian.cache.ManagedCachegetManagedCache(@NonNull String name)@NonNull Collection<com.atlassian.cache.ManagedCache>getManagedCaches()voidonClusterCacheFlush(ClusterEventWrapper wrapper)Timestamp cache region has been flushed, time to flush all local query caches.voidshutdown()
-
-
-
Method Detail
-
afterPropertiesSet
public void afterPropertiesSet() throws Exception- Specified by:
afterPropertiesSetin interfaceorg.springframework.beans.factory.InitializingBean- Throws:
Exception
-
onClusterCacheFlush
@EventListener public void onClusterCacheFlush(ClusterEventWrapper wrapper)
Timestamp cache region has been flushed, time to flush all local query caches. Due to nature of cluster events, nodes other than the flush triggering node may have staled data until this event is propagated to them. In rare circumstances, this event may even not be delivered altogether. In that case, Hibernate optimistic locking is our last defence.
-
getCaches
public @NonNull Collection<com.atlassian.cache.Cache<?,?>> getCaches()
- Specified by:
getCachesin interfacecom.atlassian.cache.CacheManager
-
getManagedCaches
public @NonNull Collection<com.atlassian.cache.ManagedCache> getManagedCaches()
- Specified by:
getManagedCachesin interfacecom.atlassian.cache.CacheManager
-
flushCaches
public void flushCaches()
- Specified by:
flushCachesin interfacecom.atlassian.cache.CacheManager
-
getManagedCache
public @Nullable com.atlassian.cache.ManagedCache getManagedCache(@NonNull String name)
- Specified by:
getManagedCachein interfacecom.atlassian.cache.CacheManager
-
shutdown
public void shutdown()
- Specified by:
shutdownin interfacecom.atlassian.cache.CacheManager
-
getCachedReference
public <V> @NonNull com.atlassian.cache.CachedReference<V> getCachedReference(@NonNull String name, @NonNull com.atlassian.cache.Supplier<V> supplier)
- Specified by:
getCachedReferencein interfacecom.atlassian.cache.CacheFactory
-
getCachedReference
public <V> @NonNull com.atlassian.cache.CachedReference<V> getCachedReference(@NonNull String name, @NonNull com.atlassian.cache.Supplier<V> supplier, @NonNull com.atlassian.cache.CacheSettings required)
- Specified by:
getCachedReferencein interfacecom.atlassian.cache.CacheFactory
-
getCachedReference
public <V> @NonNull com.atlassian.cache.CachedReference<V> getCachedReference(@NonNull Class<?> owningClass, @NonNull String name, @NonNull com.atlassian.cache.Supplier<V> supplier)
- Specified by:
getCachedReferencein interfacecom.atlassian.cache.CacheFactory
-
getCachedReference
public <V> @NonNull com.atlassian.cache.CachedReference<V> getCachedReference(@NonNull Class<?> owningClass, @NonNull String name, @NonNull com.atlassian.cache.Supplier<V> supplier, @NonNull com.atlassian.cache.CacheSettings required)
- Specified by:
getCachedReferencein interfacecom.atlassian.cache.CacheFactory
-
getCache
public <K,V> @NonNull com.atlassian.cache.Cache<K,V> getCache(@NonNull String name)
- Specified by:
getCachein interfacecom.atlassian.cache.CacheFactory
-
getCache
public <K,V> @NonNull com.atlassian.cache.Cache<K,V> getCache(@NonNull Class<?> owningClass, @NonNull String name)
- Specified by:
getCachein interfacecom.atlassian.cache.CacheFactory
-
getCache
public <K,V> @NonNull com.atlassian.cache.Cache<K,V> getCache(@NonNull String name, @Nullable com.atlassian.cache.CacheLoader<K,V> loader)
- Specified by:
getCachein interfacecom.atlassian.cache.CacheFactory
-
getCache
public <K,V> @NonNull com.atlassian.cache.Cache<K,V> getCache(@NonNull String name, @Nullable com.atlassian.cache.CacheLoader<K,V> loader, @NonNull com.atlassian.cache.CacheSettings required)
- Specified by:
getCachein interfacecom.atlassian.cache.CacheFactory
-
-