0

Spring + iBatis で Tomcat に取り組んでいる Hessian サービスがあります。結果をキャッシュする方法を考えています...

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 へのクエリです。

サービスで DBMS を初めて照会する (サーバーの再起動後) getAccounts を呼び出し、次の呼び出しでキャッシュを使用する方法を教えてください。

4

1 に答える 1

0

解決しました。解決策は追加することでした

<settings cacheModelsEnabled="true" />

私のsqlMapConfigファイルに。

于 2010-04-18T17:28:57.890 に答える