ehcache缓存同步
发布时间: 2025-02-14 04:35:36
1. 刷新ehcache缓存怎么刷新
spring 配置文件 <bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean"> <property name="configLocation"> <value>classpath:config/ehcache.xml </value> </property> </bean> <bean id="baseCache" class="org.springframework.cache.ehcache.EhCacheFactoryBean"> <property name="cacheManager" ref="cacheManager" /> <property name="cacheName"> <value>cacheNameXXXX</value> </property> </bean> 在代码中使用的时候从springContext中取到baseCache 存: baseCache.put(new Element(key,value)); 取:baseCache.get(key); 缓存自动刷新:可以在执行更新、删除数据库操作的时候同时对缓存进行更新,也可以直接清除缓存,下一次查询时再加载,毕竟缓存中的数据不是经常更改的数据。
热点内容