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

Popular posts from this blog

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -