我创建了新的grails 3.0.3应用程序,如下所示:Grails create-app cache_test
添加了一个控制器和一个方法:
package cache_test
import grails.plugin.cache.Cacheable
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.cache.CacheManager
class IndexController {
@Autowired
CacheManager grailsCacheManager
@Cacheable(value = "index")
def index() {
System.err.println("Invoked")
render("Hello man")
}}
并且我期望index()方法的结果在第一次调用后将在缓存中,然而,每次我发送请求时都会调用该方法。
我做错了什么?
似乎有一个grails缓存插件回归。
我必须为控制器编写我自己的拦截器,它基本上通过请求的url缓存响应。
丑陋,bug,但工作https://github.com/vkorobkov/grails-3-caching-workaround/