public class TransactionalCacheFactory extends Object implements LockFactory, 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 and Description |
---|
TransactionalCacheFactory(com.atlassian.cache.CacheFactory cacheFactory,
LockFactory lockFactory,
SynchronizationManager synchronizationManager,
ConfluenceMonitoring confluenceMonitoring) |
Modifier and Type | Method and 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 Use
getTxCache(String) |
<K,V> @NonNull com.atlassian.cache.Cache<K,V> |
getCache(@NonNull String name)
Deprecated.
since 7.5 Use
getTxCache(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 Use
getTxCache(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 Use
getTxCache(String, CacheLoader) |
<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 Use
getTxCache(String) |
<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) |
Lock |
getLock(String cacheName)
Deprecated.
since 7.5 not supported
|
<K,V> TransactionAwareCache<K,V> |
getTxCache(String cacheName) |
<K,V> TransactionAwareCache<K,V> |
getTxCache(String cacheName,
com.atlassian.cache.CacheLoader<K,V> loader) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
from
public TransactionalCacheFactory(com.atlassian.cache.CacheFactory cacheFactory, LockFactory lockFactory, SynchronizationManager synchronizationManager, ConfluenceMonitoring confluenceMonitoring)
@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)
getTxCache(String, CacheLoader)
getCache
in interface com.atlassian.cache.CacheFactory
@Deprecated public Lock getLock(String cacheName)
LockFactory
Lock.tryLock()
or Lock.lock()
on the returned object to
acquire the lock.getLock
in interface LockFactory
public void clearCurrentThreadTransactionalCaches()
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.
CacheManager.flushCaches()
public <K,V> TransactionAwareCache<K,V> getTxCache(String cacheName, com.atlassian.cache.CacheLoader<K,V> loader)
getTxCache
in interface TransactionAwareCacheFactory
public <K,V> TransactionAwareCache<K,V> getTxCache(String cacheName)
getTxCache
in interface TransactionAwareCacheFactory
@Deprecated public <K,V> @NonNull com.atlassian.cache.Cache<K,V> getCache(@NonNull String name, @NonNull Class<K> keyType, @NonNull Class<V> valueType)
getTxCache(String)
getCache
in interface com.atlassian.cache.CacheFactory
@Deprecated public <K,V> @NonNull com.atlassian.cache.Cache<K,V> getCache(@NonNull Class<?> owningClass, @NonNull String name)
getTxCache(String)
getCache
in interface com.atlassian.cache.CacheFactory
@Deprecated public <K,V> @NonNull com.atlassian.cache.Cache<K,V> getCache(@NonNull String name, com.atlassian.cache.CacheLoader<K,V> loader)
getTxCache(String, CacheLoader)
getCache
in interface com.atlassian.cache.CacheFactory
@Deprecated public <K,V> @NonNull com.atlassian.cache.Cache<K,V> getCache(@NonNull String name)
getTxCache(String)
getCache
in interface com.atlassian.cache.CacheFactory
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)
getCachedReference
in interface com.atlassian.cache.CacheFactory
public <V> @NonNull com.atlassian.cache.CachedReference<V> getCachedReference(@NonNull String name, @NonNull com.atlassian.cache.Supplier<V> supplier)
getCachedReference
in interface com.atlassian.cache.CacheFactory
public <V> @NonNull com.atlassian.cache.CachedReference<V> getCachedReference(@NonNull Class<?> owningClass, @NonNull String name, @NonNull com.atlassian.cache.Supplier<V> supplier)
getCachedReference
in interface com.atlassian.cache.CacheFactory
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)
getCachedReference
in interface com.atlassian.cache.CacheFactory
Copyright © 2003–2021 Atlassian. All rights reserved.