zoukankan      html  css  js  c++  java
  • 缓存 ehcache

    只是用于自己记录,防止日后忘记,回看所用

    第一步:配置ehcahe 缓存

    <?xml version="1.0" encoding="UTF-8"?>
    
    <ehcache>
        <!--
              磁盘存储:将缓存中暂时不使用的对象,转移到硬盘,类似于Windows系统的虚拟内存
               path:指定在硬盘上存储对象的路径
        -->
        <diskStore path="C:ehcache" />
    
        <!--
             defaultCache:默认的缓存配置信息,如果不加特殊说明,则所有对象按照此配置项处理
             maxElementsInMemory:设置了缓存的上限,最多存储多少个记录对象
             eternal:代表对象是否永不过期
             overflowToDisk:当内存中Element数量达到maxElementsInMemory时,Ehcache将会Element写到磁盘中
        -->
        <defaultCache
                maxElementsInMemory="100"
                eternal="true"
                overflowToDisk="true"/>
    
        <!--
            下面这是自己配置了一个缓存
        -->
        <cache
                name="a"
                maxElementsInMemory="100"
                eternal="true"
                overflowToDisk="true"/>
    </ehcache>

    第二步: 整合spring 和 ehcahe(即将ehcache 以bean的方式注入到 IOC 容器中)

    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xmlns:cache="http://www.springframework.org/schema/cache"
           xmlns:context="http://www.springframework.org/schema/context"
           xmlns:aop="http://www.springframework.org/schema/aop"
           xsi:schemaLocation="
               http://www.springframework.org/schema/beans
               http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
               http://www.springframework.org/schema/aop
               http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
               http://www.springframework.org/schema/context
               http://www.springframework.org/schema/context/spring-context-3.0.xsd
               http://www.springframework.org/schema/cache
               http://www.springframework.org/schema/cache/spring-cache-3.1.xsd">
    
        <bean id="ehCacheManager" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean">
            <property name="configLocation" value="classpath:ehcache.xml" />
            <property name="shared" value="true"/>
        </bean>
    
        <!-- 开启spring缓存 -->
        <!-- 注解开发启动 -->
        <cache:annotation-driven cache-manager="cacheManager" />
    
        <bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheCacheManager">
            <property name="cacheManager" ref="ehCacheManager"></property>
        </bean>
    </beans>

    第三步: 就可以在方法或者其他位置上使用注解驱动,来使用缓存技术啦

    (后期有待完善,望体谅)

  • 相关阅读:
    RN起步常见问题
    spa(单页应用)中,使用history模式时,微信长按识别二维码在ios下失效的问题
    vue 使用axios 跨域请求数据的问题
    vue 使用axios 跨域请求数据的问题
    vue 集成 axios 发送post请求 payload导致后台无法接收到数据问题
    vue-cli 脚手架目录结构说明
    vue-cli 前端开发,后台接口跨域代理调试问题
    ios video标签部分mp4文件无法播放的问题
    青岛旅游攻略
    iOS8使用TestFlight进行内部测试功能尝鲜
  • 原文地址:https://www.cnblogs.com/helloqiufei/p/11756621.html
Copyright © 2011-2022 走看看