首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >未配置带有CacheDecoratorFactory的Spring的Ehcache

未配置带有CacheDecoratorFactory的Spring的Ehcache
EN

Stack Overflow用户
提问于 2013-10-09 10:56:15
回答 2查看 5.8K关注 0票数 4

我正在用Spring项目实现ehcache,但没有成功。

下面是我在applicationContext.xml中的设置:

代码语言:javascript
复制
<ehcache:annotation-driven />
<bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean">
    <property name="configLocation" value="/META-INF/spring/ehcache.xml" />
</bean>

下面是我在ehcache.xml中的设置:

代码语言:javascript
复制
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://ehcache.org/ehcache.xsd">    

    <diskStore path="java.io.tmpdir" /> 
    <defaultCache eternal="true" maxElementsInMemory="100" overflowToDisk="false" />
    <cache name="listTop" maxElementsInMemory="10" eternal="true" overflowToDisk="false" />

</ehcache>

下面是我的实现类:

代码语言:javascript
复制
@Cacheable(cacheName="listTop")
public void listTop(News news, String regionCode, Integer count, Integer categoryId, String listType){
//code here//
}

我收到以下消息,似乎缓存未配置:

代码语言:javascript
复制
1827 DEBUG net.sf.ehcache.config.BeanHandler  - Ignoring ehcache attribute xmlns:xsi
1827 DEBUG net.sf.ehcache.config.BeanHandler  - Ignoring ehcache attribute xsi:noNamespaceSchemaLocation
1828 DEBUG net.sf.ehcache.config.DiskStoreConfiguration  - Disk Store Path: C:\Users\TOMMY~1.LOC\AppData\Local\Temp\
1847 DEBUG net.sf.ehcache.util.PropertyUtil  - propertiesString is null.
1860 DEBUG net.sf.ehcache.config.ConfigurationHelper  - No CacheManagerEventListenerFactory class specified. Skipping...
1918 DEBUG net.sf.ehcache.Cache  - No BootstrapCacheLoaderFactory class specified. Skipping...
1918 DEBUG net.sf.ehcache.Cache  - CacheWriter factory not configured. Skipping...
1918 DEBUG net.sf.ehcache.config.ConfigurationHelper  - No CacheExceptionHandlerFactory class specified. Skipping...
1932 DEBUG net.sf.ehcache.Cache  - No BootstrapCacheLoaderFactory class specified. Skipping...
1932 DEBUG net.sf.ehcache.Cache  - CacheWriter factory not configured. Skipping...
1932 DEBUG net.sf.ehcache.config.ConfigurationHelper  - No CacheExceptionHandlerFactory class specified. Skipping...
1954 DEBUG net.sf.ehcache.store.MemoryStore  - Initialized net.sf.ehcache.store.MemoryStore for listTop
1991 DEBUG net.sf.ehcache.statistics.extended.ExtendedStatisticsImpl  - Mocking Pass-Through Statistic: LOCAL_OFFHEAP_SIZE
1993 DEBUG net.sf.ehcache.statistics.extended.ExtendedStatisticsImpl  - Mocking Pass-Through Statistic: LOCAL_OFFHEAP_SIZE_BYTES
1994 DEBUG net.sf.ehcache.statistics.extended.ExtendedStatisticsImpl  - Mocking Pass-Through Statistic: LOCAL_DISK_SIZE
1994 DEBUG net.sf.ehcache.statistics.extended.ExtendedStatisticsImpl  - Mocking Pass-Through Statistic: LOCAL_DISK_SIZE_BYTES
1994 DEBUG net.sf.ehcache.statistics.extended.ExtendedStatisticsImpl  - Mocking Pass-Through Statistic: WRITER_QUEUE_LENGTH
1994 DEBUG net.sf.ehcache.statistics.extended.ExtendedStatisticsImpl  - Mocking Pass-Through Statistic: REMOTE_SIZE
1995 DEBUG net.sf.ehcache.statistics.extended.ExtendedStatisticsImpl  - Mocking Pass-Through Statistic: LAST_REJOIN_TIMESTAMP
2012 DEBUG net.sf.ehcache.statistics.extended.ExtendedStatisticsImpl  - Mocking Operation Statistic: OFFHEAP_GET
2013 DEBUG net.sf.ehcache.statistics.extended.ExtendedStatisticsImpl  - Mocking Operation Statistic: OFFHEAP_PUT
2014 DEBUG net.sf.ehcache.statistics.extended.ExtendedStatisticsImpl  - Mocking Operation Statistic: OFFHEAP_REMOVE
2014 DEBUG net.sf.ehcache.statistics.extended.ExtendedStatisticsImpl  - Mocking Operation Statistic: DISK_GET
2014 DEBUG net.sf.ehcache.statistics.extended.ExtendedStatisticsImpl  - Mocking Operation Statistic: DISK_PUT
2015 DEBUG net.sf.ehcache.statistics.extended.ExtendedStatisticsImpl  - Mocking Operation Statistic: DISK_REMOVE
2015 DEBUG net.sf.ehcache.statistics.extended.ExtendedStatisticsImpl  - Mocking Operation Statistic: XA_COMMIT
2015 DEBUG net.sf.ehcache.statistics.extended.ExtendedStatisticsImpl  - Mocking Operation Statistic: XA_ROLLBACK
2016 DEBUG net.sf.ehcache.statistics.extended.ExtendedStatisticsImpl  - Mocking Operation Statistic: XA_RECOVERY
2017 DEBUG net.sf.ehcache.statistics.extended.ExtendedStatisticsImpl  - Mocking Operation Statistic: CLUSTER_EVENT
2017 DEBUG net.sf.ehcache.statistics.extended.ExtendedStatisticsImpl  - Mocking Operation Statistic: NONSTOP
2024 DEBUG net.sf.ehcache.Cache  - Initialised cache: listTop
2024 DEBUG net.sf.ehcache.config.ConfigurationHelper  - CacheDecoratorFactory not configured. Skipping for 'listTop'.
2024 DEBUG net.sf.ehcache.config.ConfigurationHelper  - CacheDecoratorFactory not configured for defaultCache. Skipping for 'listTop'.

有没有人知道并提供帮助?非常感谢。

EN

回答 2

Stack Overflow用户

发布于 2014-05-12 21:22:39

您需要告诉EhCache将装饰器应用于已定义的缓存,如下所示(并且您必须实现MyCacheDecoratorFactory来执行您想要的操作):

代码语言:javascript
复制
<cache name="listTop" maxElementsInMemory="10" eternal="true" overflowToDisk="false" ><cacheDecoratorFactory class="com.test.MyCacheDecoratorFactory", properties="blah=true,someValue=2000" /></cache>
票数 3
EN

Stack Overflow用户

发布于 2019-05-22 16:25:49

缓存不工作与CacheDecoratorFactory无关。这些是调试日志,告诉您没有使用CacheDecoratorFactory

CacheDecorator是开发人员向缓存添加功能的一种方式。更多关于Ehcache 2.8 documentation的信息。

请注意,3.0中的CacheDecoratorFactory类消失了

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/19262274

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档