mybaits二十五:mybatis整合ehcache
生活随笔
收集整理的這篇文章主要介紹了
mybaits二十五:mybatis整合ehcache
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
?1. 整合需要的ehcache的jar包
?ehcache-core 包依賴 sfl4j-api,slf4j-log4j12包
?mybatis-ehcache是將mybatis和ehcache適配起來的包
2.整合還需要一個ehcache.xml文件
??
xml文件配置如下?
<ehcache><!-- 磁盤存儲:將緩存中暫時不使用的對象,轉移到硬盤,類似于Windows系統的虛擬內存path:指定在硬盤上存儲對象的路徑--><diskStore path="E:\ehcache" /><!-- defaultCache:默認的緩存配置信息,如果不加特殊說明,則所有對象按照此配置項處理maxElementsInMemory:設置了緩存的上限,最多存儲多少個記錄對象eternal:代表對象是否永不過期timeToIdleSeconds:最大的發呆時間timeToLiveSeconds:最大的存活時間overflowToDisk:是否允許對象被寫入到磁盤--><defaultCache maxElementsInMemory="10000" eternal="false"timeToIdleSeconds="120" timeToLiveSeconds="120" overflowToDisk="true" /><!-- cache:為指定名稱的對象進行緩存的特殊配置name:指定對象的完整名--><cache name="com.zbaccp.entity.Person" maxElementsInMemory="10000" eternal="false"timeToIdleSeconds="300" timeToLiveSeconds="600" overflowToDisk="true" /></ehcache>3. 在mapper.xml中使用緩存即可
<cache type="org.mybatis.caches.ehcache.EhcacheCache"></cache>?
?
?
總結
以上是生活随笔為你收集整理的mybaits二十五:mybatis整合ehcache的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: IDE快捷键
- 下一篇: mybaits二十六:mybatis,s