我在Spring + iBatis上有一个Hessian服务,在Tomcat上工作。我想知道如何缓存结果...
我在sqlmap文件中进行了以下配置:
<sqlMap namespace="Account">
<cacheModel id="accountCache" type="MEMORY" readOnly="true" serialize="false">
<flushInterval hours="24"/>
<flushOnExecute statement="Account.addAccount"/>
<flushOnExecute statement="Account.deleteAccount"/>
<property name="reference-type" value="STRONG" />
</cacheModel>
<typeAlias alias="Account" type="domain.Account" />
<select id="getAccounts" resultClass="Account" cacheModel="accountCache">
fix all;
select id, name, pin from accounts;
</select>
<select id="getAccount" parameterClass="Long" resultClass="Account" cacheModel="accountCache">
fix all;
select id, name, pin from accounts where id=#id#;
</select>
<insert id="addAccount" parameterClass="Account">
fix all;
insert into accounts (id, name, pin) values (#id#, #name#, #pin#);
</insert>
<delete id="deleteAccount" parameterClass="Long">
fix all;
delete from accounts where id = #id#;
</delete>
</sqlMap>然后我做了一些测试。我有一个hessian客户端应用程序。我多次调用getAccounts,每次调用之后都是对DBMS的查询。
如何使我的服务仅在第一次(服务器重启后)调用getAccounts时查询数据库管理系统,并使后续调用使用缓存?
发布于 2010-04-19 01:28:58
解决了。解决方案是添加
<settings cacheModelsEnabled="true" />添加到我的sqlMapConfig文件。
https://stackoverflow.com/questions/2662315
复制相似问题