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:
Thomas Darimont
2015-03-04 10:56:35 +01:00
committed by Christoph Strobl
parent c662c46d02
commit a8e4659f75
2 changed files with 144 additions and 0 deletions

View File

@@ -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;
}
}