简体   繁体   English

grails 3.0.3缓存不起作用

[英]grails 3.0.3 caching does not work

I created new grails 3.0.3 application like: grails create-app cache_test 我创建了新的grails 3.0.3应用程序,例如:grails create-app cache_test

Added one single controller into there with one method: 使用一种方法在其中添加了一个控制器:

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")
    }}

And I expect that index() method result will be in the cache after the first invocation, however, this method is invoking each time I send request. 而且我希望index()方法的结果将在第一次调用后出现在缓存中,但是,此方法在每次发送请求时都会调用。

What did I wrong? 我怎么了

Seems there is a regression of grails cache plugin. 似乎有grails缓存插件的回归。

I had to write my own interceptor for controllers which basically caches the response by request's URLs. 我必须为控制器编写自己的拦截器,该拦截器基本上是按请求的URL缓存响应。

Ugly, buggy but works https://github.com/vkorobkov/grails-3-caching-workaround/ 丑陋,越野车,但可以工作https://github.com/vkorobkov/grails-3-caching-workaround/

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

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