DATAREDIS-375 - Avoid repeatedly decorating a cache.
Previously a transactional RedisCacheManager decorated a cache with the TransactionAwareCacheDecorator twice. We now make sure that a particular cache is only decorated once with a TransactionAwareCacheDecorator. Original Pull Request: #128
This commit is contained in:
committed by
Christoph Strobl
parent
c662c46d02
commit
a8e4659f75
@@ -300,4 +300,22 @@ public class RedisCacheManager extends AbstractTransactionSupportingCacheManager
|
||||
|
||||
super.afterPropertiesSet();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see
|
||||
org.springframework.cache.transaction.AbstractTransactionSupportingCacheManager#decorateCache(org.springframework.cache.Cache)
|
||||
*/
|
||||
@Override
|
||||
protected Cache decorateCache(Cache cache) {
|
||||
|
||||
if (isCacheAlreadyDecorated(cache)) {
|
||||
return cache;
|
||||
}
|
||||
|
||||
return super.decorateCache(cache);
|
||||
}
|
||||
|
||||
protected boolean isCacheAlreadyDecorated(Cache cache) {
|
||||
return isTransactionAware() && cache instanceof TransactionAwareCacheDecorator;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user