iBatisの結果キャッシュ
iBatisのSQL設定ファイルで次のようにして結果キャッシュの指定ができる
<cacheModel id="test.cache" type="LRU"> <flushInterval hours="24"/> <flushOnExecute statement="test.refresh"/> <property name="size" value="200"/> </cacheModel>
これはLRUで最大24時間、200件のキャッシュを行う指定となる。またキャッシュを無効にする条件として test.refreshを指定している。
あとはこのキャッシュ設定を適用するselectでcacheModelとして指定する
<select id="test.getAll" resultClass="test.Entry" cacheModel="test.cache">
ちょっとTIPS:cacheModelはいくつも定義できるのでそれぞれのデータで最適なcache設定にできる