Class TransactionalCacheFactory
- java.lang.Object
-
- com.atlassian.confluence.cache.TransactionalCacheFactory
-
- All Implemented Interfaces:
com.atlassian.cache.CacheFactory
,TransactionAwareCacheFactory
public class TransactionalCacheFactory extends Object implements com.atlassian.cache.CacheFactory, TransactionAwareCacheFactory
A cache factory that produces transactional caches. These caches perform their updates only when the current transaction is successfully committed. Caches obtained outside of a transaction will pass updates immediately to the target cache while posting a warning to the cache factory log.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
Constructors Constructor Description TransactionalCacheFactory(com.atlassian.cache.CacheFactory cacheFactory, LockFactory lockFactory, SynchronizationManager synchronizationManager, ConfluenceMonitoring confluenceMonitoring)
Deprecated, for removal: This API element is subject to removal in a future version.since 8.0TransactionalCacheFactory(com.atlassian.cache.CacheFactory cacheFactory, SynchronizationManager synchronizationManager, ConfluenceMonitoring confluenceMonitoring)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
clearCurrentThreadTransactionalCaches()
Intended for use in testing.<K,V>
@NonNull com.atlassian.cache.Cache<K,V>getCache(@NonNull Class<?> owningClass, @NonNull String name)
Deprecated.since 7.5 UsegetTxCache(String)
<K,V>
@NonNull com.atlassian.cache.Cache<K,V>getCache(@NonNull String name)
Deprecated.since 7.5 UsegetTxCache(String)
<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)
<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)
<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)
-
-
-
Constructor Detail
-
TransactionalCacheFactory
public TransactionalCacheFactory(com.atlassian.cache.CacheFactory cacheFactory, SynchronizationManager synchronizationManager, ConfluenceMonitoring confluenceMonitoring)
- Since:
- 8.0
-
TransactionalCacheFactory
@Deprecated(since="8.0", forRemoval=true) public TransactionalCacheFactory(com.atlassian.cache.CacheFactory cacheFactory, LockFactory lockFactory, SynchronizationManager synchronizationManager, ConfluenceMonitoring confluenceMonitoring)
Deprecated, for removal: This API element is subject to removal in a future version.since 8.0
-
-
Method Detail
-
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
public <K,V> TransactionAwareCache<K,V> getTxCache(String cacheName)
- 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 public <K,V> @NonNull com.atlassian.cache.Cache<K,V> getCache(@NonNull String name)
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
-
-