在ibatis的map文件中添加
- <cacheModel id="cityradio-cache" type="LRU" readOnly="false" serialize="true">
- <flushInterval minutes="1"/>
- <property name="cache-size" value="5000"/>
- </cacheModel>
<flushInterval minutes="1"/> : minutes属性表示多少缓存上的数据保存多少分钟
<property name="cache-size" value="5000"/> : value属性表示缓存的空间大小
然后就可以在指定SQL语句上添加属性:
cacheModel="cityradio-cache"
并且将所需的属性类实现java.io.Serializable接口