如何清除方法cacheinterceptor缓存

时间:2012-10-17 09:05:29

标签: ehcache clear-cache

我正在开发一个Web应用程序,我在其中编写了一个方法,在该方法中,我调用了一个json url并解析并存储在pojo类中。

我只是使用methodcacheinterceptor概念缓存此方法,我的xml配置如下:

<bean id="methodCacheInterceptor"
    class="web.app.services.MethodCacheInterceptor">
    <property name="cache">
        <ref local="methodCache" />
    </property>
</bean>

<bean id="methodCache" class="org.springframework.cache.ehcache.EhCacheFactoryBean">
    <property name="cacheManager">
        <ref local="cacheManager" />
    </property>
    <property name="cacheName">
        <value>videoItemsCache</value>
    </property>
</bean>

<bean id="cacheManager"
    class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean">
    <property name="configLocation">
        <value>/WEB-INF/ehcache.xml</value>
    </property>
</bean>

<bean id="methodCachePointCut"
    class="org.springframework.aop.support.RegexpMethodPointcutAdvisor">
    <property name="advice">
        <ref local="methodCacheInterceptor" />
    </property>
    <property name="patterns">
        <list>
            <value>.*web.app.services.ItemCollectionImpl.getCollection</value>
            <value>.*web.app.services.ItemCollectionImpl.buildCollection</value>
        </list>
    </property>
</bean>

我设置了20分钟的缓存时间。它完美无缺!

我想要的只是我要覆盖的特定活动&amp;清除那些缓存,下次我访问页面时,我希望执行整个方法,不应从缓存中加载数据(我想清除缓存)。

FYI

CacheManager.getInstance()。getCacheNames() - 这会打印我在xml配置中给出的cachename。

我尝试过CacheManager.getInstance()。clearAll(),删除所有方法,但它不起作用!!

任何人都可以帮助我!

提前致谢。

0 个答案:

没有答案
相关问题