我有一个关于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时查询DBMS,并为下面的调用使用缓存?