What is @CacheResult?
@CacheResult is a Spring concept, part of their Cache Abstraction. Feign does not have first class support for these constructs, but you can use them in concert.
First, adding these annotations to Interfaces is not recommended. See Enable caching annotations in the Spring Documentation
It is recommended that you add the annotations to a concrete class. For example:
public class UserRepository {
// our feign client
private GitHub gitHub;
// find the github user and cache the result
@CacheResult
public User findByName(String name) {
return this.gitHub.findUser(name);
}
}
In this example, Feign is responsible for calling the API and the UserRespository is responsible for caching the results. Hope this helps.
This is a question regarding Spring Cache Abstraction usage and not Feign.
Most helpful comment
@CacheResultis a Spring concept, part of their Cache Abstraction. Feign does not have first class support for these constructs, but you can use them in concert.First, adding these annotations to Interfaces is not recommended. See Enable caching annotations in the Spring Documentation
It is recommended that you add the annotations to a concrete class. For example:
In this example, Feign is responsible for calling the API and the
UserRespositoryis responsible for caching the results. Hope this helps.