Cache


ActiveRecord can use caching to greatly improve performance. The following code is an example of Cache usage:

public void list() {
List<Blog> blogList = Blog.dao. findByCache("cacheName", "key", "select * from blog");
setAttr("blogList", blogList).render("list.html");
}

The cacheName in the findByCache method in the above example needs to be configured in ehcache.xml, such as: <cache name="cacheName" ...>. In addition, the Model.paginateByCache(…), Db.findByCache(…), and Db.paginateByCache(…) methods all provide cache support. When using it, you only need to pass in the cacheName, key and configure the corresponding cacheName in ehccache.xml.