views:

136

answers:

1

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.

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.

+2  A: 

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. 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 (e.g. write trough cache), but if database is changed externally you can only rely on the cace expiration.

Eugene Kuleshov