java - Cache object without it being a side effect [Play Framework] -


this question in reference play 2.2 java.

i have list of items retrieved web service. list required frequently, caching list locally.

i have set method client code may call list transparently. method first check cache, falling web service if list not present locally.

the issue have in regenerating cached list web service. can't use cache.getorelse method, because requires instance of list, , play.libs.ws returns promise<ws.response> map promise<list>.

my current strategy looks following:

  1. query cache list, , return result wrapped in promise
  2. flatmap promise, returning wrapped list if present, or calling web service adapter, , returning returned promise<list>

now, before return promise web service adapter in step 2, register callback on promise add list cache when redeemed.

what want know is: there way can add list form web service cache, without being side effect of process?

i had tried strategy, mapped returned promise, cached it, , returned list, seems more blatant side effect. i'd avoid if can.


Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -