ehcache 异常net.sf.ehcache.CacheException: When configured copyOnRead or copyOnWrite, a Store will onl
来源:互联网 发布:photo picture软件 编辑:程序博客网 时间:2024/05/20 00:11
之前遇到“缓存的对象变更后,自动更新到缓存中”的问题,参照http://blog.csdn.net/haiyang4988/article/details/53201618
然后就配置了copyOnWrite=“true”、copyOnRead=“true” 结果又出现了异常(缓存对象的时候)
net.sf.ehcache.CacheException: When configured copyOnRead or copyOnWrite, a Store will only accept Serializable values
最后是这样解决的,在ehcache.xml中配置
<cache name="conCache"
maxElementsOnDisk="20000"
maxElementsInMemory="5000"
eternal="true"
overflowToDisk="false"
diskPersistent="false"
copyOnRead="true"
copyOnWrite="true"
memoryStoreEvictionPolicy="LRU">
<copyStrategy class="com.xxx.MyCopyStrategy" />
</cache>
然后MyCopyStrategy.java中代码如下
package com.xxxx.ehCache;import java.io.Serializable;import net.sf.ehcache.Element;import net.sf.ehcache.store.compound.ReadWriteCopyStrategy;/** * 序列化要缓存的对象,否则设置 copyOnRead="true" copyOnWrite="true" 缓存对象的时候可能报序列化错误 * @author CUIJIAJUN * * @date 2016年11月24日 下午2:52:03 * */public class MyCopyStrategy implements ReadWriteCopyStrategy<Element> {@Overridepublic Element copyForWrite(Element value) {if(value != null){//System.out.println("value==="+value); Object temp=(Serializable)value.getObjectValue();return new Element(value.getObjectKey(),temp);}return value;}@Overridepublic Element copyForRead(Element storedValue) {if(storedValue != null){//System.out.println("storedValue==="+storedValue); Object temp=(Serializable)storedValue.getObjectValue();return new Element(storedValue.getObjectKey(),temp);}return storedValue;}}
0 0
- ehcache 异常net.sf.ehcache.CacheException: When configured copyOnRead or copyOnWrite, a Store will onl
- java.lang.NoClassDefFoundError: net/sf/ehcache/CacheException
- net.sf.ehcache.CacheException:error setting options
- Exception in thread "main" java.lang.NoClassDefFoundError: net/sf/ehcache/CacheException异常处理
- hibernate报错java.lang.NoClassDefFoundError: net/sf/ehcache/CacheException
- Maven项目遇到java.lang.NoClassDefFoundError: net/sf/ehcache/CacheException
- hibernate报错java.lang.NoClassDefFoundError: net/sf/ehcache/CacheException
- java异常之 Could not load net.sf.ehcache.store.disk.DiskStore$KeySet....
- hibernate Exception in thread "main" java.lang.NoClassDefFoundError: net/sf/ehcache/CacheException
- net.sf.ehcache.CacheException: Another unnamedCacheManager already exists in the same VM
- Caused by: net.sf.ehcache.CacheException: java.io.StreamCorruptedException: invalid stream header: 0
- net.sf.ehcache.CacheException: Another unnamed CacheManager already exists in the same VM.
- Hibernate4 net.sf.ehcache.Ehcache.getCacheConfiguration错误
- Spring配置时异常net/sf/ehcache/E…
- this web application instance has been stopped already. Could not load net.sf.ehcache.store.compoun
- ERROR net.sf.ehcache.distribution.MulticastRMICacheManagerPeerProvider
- ehcache-core版本导致异常 tried to access method net.sf.ehcache.config.CacheConfiguration.<init>()V from cl
- Tomcat每次启动出现net.sf.ehcache.util.UpdateChecker doCheck
- Hub与Switch的帧的广播细节
- 病毒木马查杀实战第025篇:JS下载者脚本木马的分析与防御
- 以Graphicslayer为管理组来管理Element.
- wemall app商城源码Fragment中监听onKey事件
- MySQL函数大全 及用法示例
- ehcache 异常net.sf.ehcache.CacheException: When configured copyOnRead or copyOnWrite, a Store will onl
- java在SAE中使用的相关问题总结
- iOS:实现图片的无限轮播(二)---之使用第三方库SDCycleScrollView
- jquery select 插件
- String 的compareto函数
- 不能用ajax提交文件下载的请求
- windows中以本地模式运行spark遇到“Could not locate executable null\bin\winutils.exe in the Hadoop binarie”
- android文字闪动效果
- web.xml配置文件说明