<cacheModel id="product-cache" type ="LRU" readOnly=”true” serialize=”false”> <flushInterval hours="24"/> <flushOnExecute statement="insertProduct"/> <flushOnExecute statement="updateProduct"/> <flushOnExecute statement="deleteProduct"/> <property name=”cache-size” value=”1000” /> </cacheModel>
根据cacheModel中flush元素的内容,上面的例子每24小时刷新一次。一个cacheModel只能有一个flushInteval元素,它可以使用hours,minutes,seconds或milliseconds来设定。另外,当insertProduct,updateProduct或deleteProduct的Mapped Statement执行时,缓存也被刷新。cacheModel可以定义任意多的flushOnExecute元素。某些cache model的实现可能需要另外的属性,如上面的“cache-size”属性。在LRU cache model中,cache-size指定了缓存储存的项数。一旦配置了cache model,您可以指定mapped statement使用的cache model,