自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

iBATIS緩存cacheModel屬性淺析

開(kāi)發(fā) 后端
iBATIS緩存cacheModel屬性的應(yīng)用使得在Mapped Statement中緩存常用的數(shù)據(jù),那么本文將會(huì)給你介紹iBATIS緩存cacheModel屬性的信息。

iBATIS緩存模型可以在Mapped Statement中使用,在內(nèi)存中緩存常用的數(shù)據(jù)。屬性cacheModel 定義查詢mapped statement 的緩存。每一個(gè)查詢mapped statement 可以使用不同或相同的cacheModel。以下給出個(gè)例子:

  1. ﹤cacheModel id="product-cache" imlementation="LRU"﹥   
  2.  ﹤flushInterval hours="24"/﹥   
  3.  ﹤flushOnExecute statement="insertProduct"/﹥   
  4.  ﹤flushOnExecute statement="updateProduct"/﹥   
  5.  ﹤flushOnExecute statement="deleteProduct"/﹥   
  6.  ﹤property name="size" value="1000" /﹥   
  7. ﹤/cacheModel﹥   
  8. ﹤statement id="getProductList" parameterClass="int" cacheModel="product-cache"﹥   
  9.   select * from PRODUCT where PRD_CAT_ID = #value#   
  10. ﹤/statement﹥ 

上面例子中,“getProductList”的緩存使用 WEAK 引用類型,每 24 小時(shí)刷新一次,或當(dāng)更新的操作發(fā)生時(shí)刷新。 

Cache Model使用插件方式來(lái)支持不同的緩存算法。它的實(shí)現(xiàn)在 cacheModel 的用 type屬性來(lái)指定(如上所示)。指定的實(shí)現(xiàn)類必須實(shí)現(xiàn) CacheController接口,或是下面 4個(gè)別名中的其中之一。Cache Model 實(shí)現(xiàn)的其他配置參數(shù)通過(guò) cacheModel的 property元素來(lái)設(shè)置。目前包括以下的 4 個(gè)實(shí)現(xiàn):

◆"MEMORY” (com.ibatis.db.sqlmap.cache.memory.MemoryCacheController) 。MEMORY cache 實(shí)現(xiàn)使用 reference 類型來(lái)管理 cache 的行為。垃圾收集器可以根據(jù) reference類型判斷是否要回收 cache 中的數(shù)據(jù)。MEMORY實(shí)現(xiàn)適用于沒(méi)有統(tǒng)一的對(duì)象重用模式的應(yīng)用,或內(nèi)存不足的應(yīng)用。

◆“LRU” (com.ibatis.db.sqlmap.cache.lru.LruCacheController) 。LRU Cache 實(shí)現(xiàn)用“近期最少使用”原則來(lái)確定如何從 Cache 中清除對(duì)象。當(dāng) Cache溢出時(shí),最近最少使用的對(duì)象將被從 Cache 中清除。使用這種方法,如果一個(gè)特定的對(duì)象總是被使用,它將保留在 Cache 中,而且被清除的可能性最小。對(duì)于在較長(zhǎng)的期間內(nèi),某些用戶經(jīng)常使用某些特定對(duì)象的情況(例如,在 PaginatedList 和常用的查詢關(guān)鍵字結(jié)果集中翻頁(yè)) ,LRU Cache 是一個(gè)不錯(cuò)的選擇。

◆“FIFO” (com.ibatis.db.sqlmap.cache.fifo.FifoCacheController) 。FIFO Cache 實(shí)現(xiàn)用“先進(jìn)先出”原則來(lái)確定如何從 Cache 中清除對(duì)象。當(dāng) Cache 溢出時(shí),***進(jìn)入 Cache 的對(duì)象將從 Cache 中清除。對(duì)于短時(shí)間內(nèi)持續(xù)引用特定的查詢而后很可能不再使用的情況,F(xiàn)IFO Cache 是很好的選擇。

◆“OSCACHE” (com.ibatis.db.sqlmap.cache.oscache.OSCacheController)  。OSCACHE Cache 實(shí)現(xiàn)是OSCache2.0緩存引擎的一個(gè) Plugin。它具有高度的可配置性,分布式,高度的靈活性。

iBATIS緩存cacheModel屬性的情況就向你介紹到這里,是不是對(duì)于iBATIS緩存方面的應(yīng)用有所了解了呢?

【編輯推薦】

  1. Hibernate與iBATIS的較量淺析
  2. iBATIS實(shí)例創(chuàng)建的五大步淺析
  3. iBATIS with MapBean應(yīng)用淺析
  4. iBATIS接口應(yīng)用的淺析
  5. Oracle下iBATIS XML配置淺析
責(zé)任編輯:仲衡 來(lái)源: JavaEye
相關(guān)推薦

2009-07-22 10:42:59

iBATIS Cach

2009-07-21 11:12:00

iBATIS配置

2009-07-20 09:51:19

iBATIS.net數(shù)據(jù)庫(kù)緩存

2009-07-15 17:19:31

iBATIS Ecli

2009-07-16 09:14:26

iBATIS DAO

2009-07-17 10:32:45

iBATIS MapB

2009-07-20 18:00:16

iBATIS DAO事

2009-07-22 10:03:11

iBATIS Resu

2009-07-15 17:58:07

iBATIS 動(dòng)態(tài)映射

2009-07-16 10:23:30

iBATIS工作原理

2009-07-15 16:42:03

iBATIS讀寫(xiě)CLO

2009-07-16 13:08:09

iBATIS快速創(chuàng)建應(yīng)

2009-07-22 15:21:00

iBATIS SQLM

2009-07-22 09:44:05

iBATIS Para

2009-07-17 09:44:40

iBATIS教程

2009-07-17 10:59:59

iBATIS接口

2009-07-22 15:01:01

iBATIS SQLM

2009-07-22 16:02:14

iBATIS參數(shù)

2009-07-15 16:26:04

iBATIS Clob

2009-07-17 16:49:18

iBATIS XML配
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)