Class TransactionalCacheFactory
- All Implemented Interfaces:
com.atlassian.cache.CacheFactory
,TransactionAwareCacheFactory
Transactional caches returned by this factory make a best effort at committing changes to the underlying cache, but they don't recover well from failure (caches with failures will be flushed), and there is no way that the associated database transaction can be rolled back if the cache updates fail.
Transaction synchronization is performed via the provided SynchronizationManager
.
All updates to underlying caches are performed inside a lock on the cache to prevent other writes occurring at the same time. This applies for updates done post-commit for transaction-based caches, as well as those done via the read-through update method.
-
Constructor Summary
ConstructorsConstructorDescriptionTransactionalCacheFactory
(com.atlassian.cache.CacheFactory cacheFactory, SynchronizationManagerInternal synchronizationManager, ConfluenceMonitoring confluenceMonitoring) -
Method Summary
Modifier and TypeMethodDescriptionvoid
Intended for use in testing.<K,
V> @NonNull com.atlassian.cache.Cache<K, V> Deprecated.<K,
V> @NonNull com.atlassian.cache.Cache<K, V> Deprecated.since 7.5 UsegetTxCache(String)
<K,
V> @NonNull com.atlassian.cache.Cache<K, V> Deprecated.since 7.5 UsegetTxCache(String)
<K,
V> @NonNull com.atlassian.cache.Cache<K, V> Deprecated.since 7.5 UsegetTxCache(String, CacheLoader)
<K,
V> @NonNull com.atlassian.cache.Cache<K, V> getCache
(@NonNull String cacheName, com.atlassian.cache.CacheLoader<K, V> loader, @NonNull com.atlassian.cache.CacheSettings required) Deprecated.since 7.5 UsegetTxCache(String, CacheLoader)
<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) <K,
V> TransactionAwareCache<K, V> getTxCache
(String cacheName) <K,
V> TransactionAwareCache<K, V> getTxCache
(String cacheName, com.atlassian.cache.CacheLoader<K, V> loader) 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.CacheFactory
getReadThroughCache, getReadThroughCache
-
Constructor Details
-
TransactionalCacheFactory
public TransactionalCacheFactory(com.atlassian.cache.CacheFactory cacheFactory, SynchronizationManagerInternal synchronizationManager, ConfluenceMonitoring confluenceMonitoring) - Since:
- 9.0
-
-
Method Details
-
getCache
@Deprecated public <K,V> @NonNull com.atlassian.cache.Cache<K,V> getCache(@NonNull String cacheName, com.atlassian.cache.CacheLoader<K, V> loader, @NonNull com.atlassian.cache.CacheSettings required) Deprecated.since 7.5 UsegetTxCache(String, CacheLoader)
- Specified by:
getCache
in interfacecom.atlassian.cache.CacheFactory
-
clearCurrentThreadTransactionalCaches
public void clearCurrentThreadTransactionalCaches()Intended for use in testing. Discard all transaction-scoped caches and cached references for the current thread's transaction.Cached values will be cleared. Cached (deferred) writes will be dropped - not written to the underlying cache. The underlying non-transactional cache will not be cleared: see
CacheManager.flushCaches()
for that.- See Also:
-
CacheManager.flushCaches()
-
getTxCache
public <K,V> TransactionAwareCache<K,V> getTxCache(String cacheName, com.atlassian.cache.CacheLoader<K, V> loader) - Specified by:
getTxCache
in interfaceTransactionAwareCacheFactory
-
getTxCache
- Specified by:
getTxCache
in interfaceTransactionAwareCacheFactory
-
getCache
@Deprecated public <K,V> @NonNull com.atlassian.cache.Cache<K,V> getCache(@NonNull String name, @NonNull Class<K> keyType, @NonNull Class<V> valueType) Deprecated.since 7.5 UsegetTxCache(String)
- Specified by:
getCache
in interfacecom.atlassian.cache.CacheFactory
-
getCache
@Deprecated public <K,V> @NonNull com.atlassian.cache.Cache<K,V> getCache(@NonNull Class<?> owningClass, @NonNull String name) Deprecated.since 7.5 UsegetTxCache(String)
- Specified by:
getCache
in interfacecom.atlassian.cache.CacheFactory
-
getCache
@Deprecated public <K,V> @NonNull com.atlassian.cache.Cache<K,V> getCache(@NonNull String name, com.atlassian.cache.CacheLoader<K, V> loader) Deprecated.since 7.5 UsegetTxCache(String, CacheLoader)
- Specified by:
getCache
in interfacecom.atlassian.cache.CacheFactory
-
getCache
Deprecated.since 7.5 UsegetTxCache(String)
- Specified by:
getCache
in 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:
getCachedReference
in interfacecom.atlassian.cache.CacheFactory
-
getCachedReference
public <V> @NonNull com.atlassian.cache.CachedReference<V> getCachedReference(@NonNull String name, @NonNull com.atlassian.cache.Supplier<V> supplier) - Specified by:
getCachedReference
in 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:
getCachedReference
in 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:
getCachedReference
in interfacecom.atlassian.cache.CacheFactory
-
getTxCache(String)