5

I'm trying to cache the results of a slow network call which is contained in a method interface by following the guide at http://www.yegor256.com/2014/08/03/cacheable-java-annotation.html

I'm using netflix feign client to make the network calls and using com.jcabi.aspetcts.Cacheable to cache the results of this method.

@Headers("Accept: application/json")
public interface ApiSolutionClient {

  @Cacheable(lifetime = 30, unit = TimeUnit.MINUTES) 
  @RequestLine("GET /v1/solutions?param1={param1}&param2={param2})
  List<Solutions> getSolutions(@Param("param1") Param1 param1, @Param("param2") Param2 param2);
}

If I make repeated calls to this method within a span of 30 minutes, the data is not fetched from cache, rather network call is repeated again(I'm observing server logs as well).

How do I get it to cache the results instead of executing the method body again ?

Anoop
  • 5,540
  • 7
  • 35
  • 52
  • 1
    You must not forget to weave your binaries after compilation: http://plugin.jcabi.com/example-ajc.html – yegor256 May 23 '17 at 11:51

0 Answers0