groovy - Where to put object-cache in Grails? -
i want use caching guava-library in grails app. service class non-static field , getter best place put cache into? or should static or declared somewhere else?
basic example:
class testservice { def getcachedvalue(test test) { return testcache.get(test) } def testcache = new cachebuilder() .maximumsize(2000) .weakkeys() .weakvalues() .expireafterwrite(30, timeunit.seconds) .build( new cacheloader<test, date>() { ...
using service is best idea this. however, making static bit unnecessary since default services singletons.
the fact service singleton, , exposed not controllers other artifacts within grails application make perfect fit accessing object cache. single point of access.
Comments
Post a Comment