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?
- request variable presents only in controllers.
- 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:
- Use EhCache to cache hibernate queries.
- 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 :)
精彩评论