开发者

Cache per request in grails

I want to cache an dto, that I g开发者_如何转开发et consuming an api, in the whole request. I try to access the request variable in a service, but it don't work.

Also I had tried to create a service with request scope but it has a error in bean creation stage in spring.

Some thing like this: http://jira.codehaus.org/browse/GRAILS-4148

Can you give me any pointer?


  1. request variable presents only in controllers.
  2. You have an error because your program has no idea how to initialize request variable in service.

You are free to pass request variable to any service method as parameter.

You have 2 cache solution:

  1. Use EhCache to cache hibernate queries.
  2. Use SpringCache to cache entire methods(returned result).

P.S. I'm not a big expert in EhCache + Grails bundle but on my opinion - SprigCache is much more flexible (adjustable) than EhCache but those two providers have very different use purposes. And keep in mind that SpringCache is based on EhCache :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜