转自:http://www.169it.com/article/5994930453423417575.html
使用
SELECT sql_NO_CACHE ...
语法即可
目前流传的sql_NO_CACHE不外乎两种解释:
2.对当前query的产生的结果集不缓存至系统query cache里,则下次相同query花费时间会多点
我做了下实验,似乎两种都对。
对sql_NO_CACHE的解释及测试如下:
sql_NO_CACHE means that the query result is not cached. It does not mean that the cache is not used to answer the query.
You may use RESET QUERY CACHE to remove all queries from the cache and then your next query should be slow again. Same effect if you change the table, because this makes all cached queries invalid.
MysqL> select count(*) from users where email = 'hello';
+----------+
| count(*) |
+----------+
| 0 |
+----------+
1 row in set (7.22 sec)
MysqL> select count(*) from users where email = 'hello';
+----------+
| count(*) |
+----------+
| 0 |
+----------+
1 row in set (0.45 sec)
MysqL> select count(*) from users where email = 'hello';
+----------+
| count(*) |
+----------+
| 0 |
+----------+
1 row in set (0.45 sec)
+----------+
| count(*) |
+----------+
| 0 |
+----------+
1 row in set (0.43 sec)
================MyBatis的对CACHE的应用======================
MyBatis的flushCache和useCache的使用
(1)当为select语句时:
useCache默认为true,表示会将本条语句的结果进行二级缓存。
(2)当为insert、update、delete语句时:
useCache属性在该情况下没有。
<select id="save" parameterType="XX" flushCache="true" useCache="false">
……
</select>
update 的时候如果 flushCache="false",则当你更新后,查询的数据数据还是老的数据。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。