码迷,mamicode.com
首页 > 编程语言 > 详细

spring缓存Ehcache(入门2)源码解读

时间:2016-09-18 20:49:56      阅读:168      评论:0      收藏:0      [点我收藏+]

标签:

Ehcache缓存:

    解读:

Ehcache缓存是在继承spring缓存核心类CacheManager的基础上实现的。

    常用类:

EhCacheCacheManager:继承自CacheManager类(org.springframework.cache.CacheManager)负责管理Cache对象。
EhCacheManagerFactoryBean:是个工厂类,根据配置文件中设置的参数(配置文件会被注入工厂类对象中),新建Ehcache的CacheManager对象,其可以通过属性configLocation指定用于创建CacheManager的Ehcache配置文件的路径,通常是ehcache.xml文件的路径。

实例:

------------------------------------------------------------------------------------------------------------

<!--缓存配置-->

   <!--启用缓存注解功能-->

   <cache:annotation-driven cache-manager="cacheManger"/>

  <bean id="cacheManagerFactory" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean">
  <property name="configLocation" value="classpath:ehcache.xml"></property>
  </bean>

  <bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheCacheManager">
  <property name="cacheManager" ref="cacheManagerFactory"/>
  </bean>

------------------------------------------------------------------------------------------------------------

service层的使用可以翻看http://www.cnblogs.com/zqsky/p/5868549.html。

spring缓存Ehcache(入门2)源码解读

标签:

原文地址:http://www.cnblogs.com/zqsky/p/5882752.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!