Store by value support for ConcurrentMapCacheManager
ConcurrentMapCacheManager and ConcurrentMapCache now support the
serialization of cache entries via a new `storeByValue` attribute. If it is
explicitly enabled, the cache value is first serialized and that content
is stored in the cache.
The net result is that any further change made on the object returned
from the annotated method is not applied on the copy held in the cache.
Issue: SPR-13758
@ -46,6 +51,8 @@ public class ConcurrentMapCache extends AbstractValueAdaptingCache {
@@ -46,6 +51,8 @@ public class ConcurrentMapCache extends AbstractValueAdaptingCache {
@ -74,13 +81,40 @@ public class ConcurrentMapCache extends AbstractValueAdaptingCache {
@@ -74,13 +81,40 @@ public class ConcurrentMapCache extends AbstractValueAdaptingCache {
@ -142,4 +176,59 @@ public class ConcurrentMapCache extends AbstractValueAdaptingCache {
@@ -142,4 +176,59 @@ public class ConcurrentMapCache extends AbstractValueAdaptingCache {
this.store.clear();
}
@Override
protectedObjecttoStoreValue(ObjectuserValue){
ObjectstoreValue=super.toStoreValue(userValue);
if(this.serialization!=null){
try{
returnserializeValue(storeValue);
}
catch(Exceptionex){
thrownewIllegalArgumentException("Failed to serialize cache value '"
+userValue+"'. Does it implement Serializable?",ex);
@ -52,6 +54,10 @@ public class ConcurrentMapCacheManager implements CacheManager {
@@ -52,6 +54,10 @@ public class ConcurrentMapCacheManager implements CacheManager {
privatebooleanallowNullValues=true;
privatebooleanstoreByValue=false;
privateSerializationDelegateserialization;
/**
*ConstructadynamicConcurrentMapCacheManager,
@ -114,6 +120,37 @@ public class ConcurrentMapCacheManager implements CacheManager {
@@ -114,6 +120,37 @@ public class ConcurrentMapCacheManager implements CacheManager {
@ -141,7 +178,11 @@ public class ConcurrentMapCacheManager implements CacheManager {
@@ -141,7 +178,11 @@ public class ConcurrentMapCacheManager implements CacheManager {
@ -53,4 +59,53 @@ public class ConcurrentMapCacheTests extends AbstractCacheTests<ConcurrentMapCac
@@ -53,4 +59,53 @@ public class ConcurrentMapCacheTests extends AbstractCacheTests<ConcurrentMapCac