新的数据库访问方式
来源:互联网 发布:自己淘宝组装电脑 编辑:程序博客网 时间:2024/05/02 04:55
- <select id="GetCachedAccountsViaResultMap"
- resultMap="account-result"
- cacheModel="account-cache" >
- select *
- from Accounts
- order by Account_ID
- </select>
- 这里 需要注意的几点:select * from Accounts order by Account_ID 是SQL语句。
最主要的就是cacheModel="account-cache",指定缓存的方式,如下,是具体配置缓存的地方:
<cacheModels>
<cacheModel id="account-cache" implementation="MEMORY" >
<flushInterval hours="24"/>
<flushOnExecute statement="UpdateAccountViaInlineParameters"/>
<flushOnExecute statement="UpdateAccountViaParameterMap"/>
<flushOnExecute statement="InsertAccountViaParameterMap"/>
<property name="Type" value="Weak"/>
</cacheModel>
</cacheModels>
<cacheModel id="account-cache" implementation="MEMORY" >
<flushInterval hours="24"/>
<flushOnExecute statement="UpdateAccountViaInlineParameters"/>
<flushOnExecute statement="UpdateAccountViaParameterMap"/>
<flushOnExecute statement="InsertAccountViaParameterMap"/>
<property name="Type" value="Weak"/>
</cacheModel>
</cacheModels>
其中:implementation="MEMORY"是设置缓存的实现方式,可以指定LRU、FIFO等,有点类似于内存的页替换策略。MEMORY是最常使用的一种方式。
flushOnExecute设置的是当执行了这些语句时更新缓存,上述是存储过程。
配置好之后我进行了一个简单的测试,基本上是可以的,但也有一点问题:
1、第一次查询结果是4条记录,当我手工往数据库中插入一条记录时,第二次查询还是4条记录
2、当我把系统时间改成第二天(24小时后),再查,得到的结果是5条记录
3、当我执行了InsertAccountViaParameterMap语句插入一条记录时,再查询得到的是6条记录
也就是说:当系统中的表从不进行手工维护,也不由第三方程序修改时,可以使用数据库缓存的方式提高效率
- 新的数据库访问方式
- ASP访问数据库的方式
- 常用的数据库访问方式
- 常用的数据库访问方式
- Data Web Services:访问 IBM 数据库服务器的新方式 —— 构建 Web 服务
- cache数据库:对象方式的数据库访问
- cache数据库:对象方式的数据库访问
- 访问数据库的三种方式
- 连接访问oracle数据库的方式
- 数据库访问表的几种方式
- hibernate访问数据库的几种方式
- ADO.NET访问数据库的方式
- 数据库访问数据块的方式
- 原始的JDBC访问数据库方式
- php 访问数据库的三种方式
- web应用访问数据库的方式
- 数据库访问方式
- 数据库访问方式
- 中国版画---中华百景
- 我要开发一款更好的下载软件
- 富爸爸的投资口诀
- 方便的使用单击和双击更新DataGrid中的数据的例子
- 的用法
- 新的数据库访问方式
- Google CN居然推出了"生活"搜索
- 多元化与专业化:我的2007年度工作盘点
- 微软官方简体中文版Vs2008与MSDN下载地址(2008年2月1日发布)
- 好久没有来了
- 关于自省的思考
- 大拇指规则 (RULE OF THUMB)
- [企业管理]我父亲遇到的一个黑心老板的经历,最新进展
- 程序人生:给你讲十个特别有哲理的故事