caching - Spring Cache Abstraction with Hazelcast and time consuming method -
how using spring cache abstraction handle case, when want call method getnametimeconsumingmethod if result not in cache not want wait execution method , return result method getnameifnotincache.
@cacheable(value = "cachename", key = "#key") public string getnametimeconsumingmethod(string key) { //time consuming method } public string getnameifnotincache(string key) { //fast method if cachename not have key }
well, if key in cache, getnametimeconsumingmethod won't executed, because result returned cache. if key not in cache, want execute getnameifnotincache.
what conclude is, don't want execute inside getnametimeconsumingmethod. why don't call getnameifnotincache getnametimeconsumingmethod , return it?
Comments
Post a Comment