简体   繁体   English

Grails 1.3.1:改进的查询缓存

[英]Grails 1.3.1: Improved Query Caching

http://www.grails.org/1.3.1+Release+Notes http://www.grails.org/1.3.1+Release+Notes

Improved Query Caching 改进的查询缓存

The findAll query method now supports taking advantage of the 2nd level cache. findAll查询方法现在支持利用第二级缓存。

Book.findAll("from Book as b where b.author=:author", [author:'Dan Brown'], [cache: true])

What advantages or disadvantages of using 2nd level cache ? 使用二级缓存有哪些优缺点?

I'm developing web-server for iPhone application so i have a lot of parallel connections, DB queries, etc. 我正在为iPhone应用程序开发Web服务器,所以我有很多并行连接,数据库查询等。

Generally, the 2nd level cache holds the application data previously retrieved from the database. 通常,第二级缓存保存先前从数据库中检索到的应用程序数据。 The advantage is that you can make big savings on avoiding database calls for the same data. 这样做的好处是,可以避免对相同数据的数据库调用,从而节省大量资金。 If 2nd level cache is going to be efficient or not depends on how your app is working with the data and also on the size of the data you can store in memory. 2级缓存是否有效取决于您的应用如何处理数据,还取决于您可以存储在内存中的数据大小。 Probably the only major disadvantage is that cache need to be invalidated when data is updated in the database. 唯一的主要缺点可能是在数据库中更新数据时需要使缓存无效。 When that happens from your application, some frameworks can handle that automatically (eg write trough cache), but if database is changed externally you can only rely on the cace expiration. 当您的应用程序发生这种情况时,某些框架可以自动处理该问题(例如,写入槽缓存),但是如果从外部更改数据库,则只能依靠cace到期。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM