Ibatis OSCache緩存配置(監聽器未實現)

1. 導入oscache-2.4.jar

2.定義oscache.properties

#是否使用內存作爲緩存空間
cache.memory=true
 
#緩存管理事件監聽器,通過這個監聽器可以獲知當前Cache的運行情況 
#cache.event.listeners=com.opensymphony.oscache.plugins.clustersupport.JavaGroupsBroadcastingListener

#如果使用磁盤緩存(cache.memory=false),則需要指定磁盤存儲接口實現
#cache.persistence.class=com.opensymphony.oscache.plugins.diskpersistence.DiskPersistenceListener
 
# 磁盤緩存所使用的文件存儲路徑
# cache.path=c:\\myapp\\cache
 
# 緩存調度算法,可選的有LRU,FIFO和無限緩存(UnlimitedCache)  
 

# cache.algorithm=com.opensymphony.oscache.base.algorithm.FIFOCache
# cache.algorithm=com.opensymphony.oscache.base.algorithm.UnlimitedCache
cache.algorithm=com.opensymphony.oscache.base.algorithm.LRUCache
 
#內存緩存的最大容量
cache.capacity=1000
 
# 是否限制磁盤緩存的容量
# cache.unlimited.disk=false
 
# 基於JMS的集羣緩存同步配置
#cache.cluster.jms.topic.factory=java:comp/env/jms/TopicConnectionFactory
#cache.cluster.jms.topic.name=java:comp/env/jms/OSCacheTopic
#cache.cluster.jms.node.name=node1
 

3.定義xml

<cacheModel id="userCache" type="OSCACHE">
   <flushInterval hours="24"/>
   <flushOnExecute statement="user_space.insertUsers"/>
   <flushOnExecute statement="user_space.updateUsers"/>
   <property name="size" value="1000" />
  </cacheModel>

4.完成

發佈了36 篇原創文章 · 獲贊 3 · 訪問量 3萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章