grails - Application wide map -
i want quartz job populate map (from web services call) on regular intervals , access map web layer (to display user).
i thinking doing service (given service singleton), bit worried the recommendation not store state in service.
class mapservice { def map = [:] }
what best way this?
if not worrying keeping data in memory while app running, can use concurrenthashmap
in service , store data need. @ cache not reliable storage though.
as said, services singleton only 1 instance of service ever exists
, concurrentmap
a hash table supporting full concurrency of retrievals , adjustable expected concurrency updates.
ex:
calss myservice() { concurrenthashmap cachemap = [:] def retrievecache(string key) { cachemap[(key)] } def resetcache(){ cachemap = [:] } def dosomething(){ .. cachemap.put(key,value) } }
similar post
Comments
Post a Comment