首页 新闻 会员 周边

IBatisnet 缓存配置问题

0
悬赏园豆:10 [已关闭问题] 关闭于 2011-11-08 09:29

我配置好缓存,但是没有起作用。请高手帮我看一下。

SqlMap.config 文件 开启缓存配置。

    <settings>    

     <!-- 是否通过命名空间调用 SQL -->    

    <setting useStatementNamespaces="false"/>    

     <!-- 是否开启缓存 -->    

    <setting cacheModelsEnabled="true"/>  

</settings>

 

CacheUser.xml

 <!-- 缓存机制 -->

<cacheModels>  

    <cacheModel id="MyUserListCache" implementation="LRU">    

<!-- 设定缓存有效期,如果超过此设定值,则将此CacheModel缓存清空 -->     <flushInterval hours="24"/>     

    <flushonexecute  statement="CacheUser.sql_update"/>    

 <!--<property name="Type" value="Weak"/>-->    

 <property name="size" value="1000" />  

 </cacheModel>

</cacheModels>

<statements>

     <select id="sql_CacheSelect" cacheModel="MyUserListCache" resultMap="EntityModel.UserResult" >

            select * from UserInfo

       </select>

         <delete id="sql_Delete" parameterClass="int">

       delete from UserInfo where UserId=#UserId#

            </delete>

        <update id="sql_update" parameterClass="UserInfo">

       update UserInfo set UserName = #UserName#   where UserId = #UserId#         </update>  

</statements>

调用方法

public IList<UserInfo> CacheAllUsers()        

 {            

      return this.ExecuteQueryForList<UserInfo>("sql_CacheSelect", null);        

}

上善若水123的主页 上善若水123 | 菜鸟二级 | 园豆:210
提问于:2011-11-07 18:07
< >
分享
所有回答(1)
0

由于我后台ISqlMapper 声明 getdombuilder.Configure() as SqlMapper;

而换成Mapper.Instance();就没有问题了。

上善若水123 | 园豆:210 (菜鸟二级) | 2011-11-08 09:29
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册