Caching in Grails - what is cached by default and what can be enabled?
I'm curious about the support for database/GORM object caching provided by the Grails framework.
- What database caching is enabled by default?
- What database 开发者_C百科caching is provided by the framework but is disabled by default?
- What kind of database caching do you usually enable/disable in your Grails projects? Why?
Grails uses Hibernate for GORM, so the database caching features are actually provided by Hibernate.
The Hibernate first level cache is enabled (which only lasts approximately the time of a user request). It can not be disabled.
The Hibernate second level cache is also enabled, but can be turned off by configuration. This cache will hold data for a long time (configurable by object type) unless something invalidates the data (an update)
For heavy-read applications, second-level cache should be enabled, you will save a lot of trips to your database, and it is 100% transparent to your application (almost no cost).
Regards,
Vincent
3) We disabled disk cache overflow. Had to explicitly create ehcache.xml
for that, from ehcache-core-1.7.1.jar/ehcache-failsafe.xml
.
Disk cache overflow only made problems for us due to being slow and IO error prone.
精彩评论