Hystrix javanica cache and JCache

125 Views Asked by At

I have a SpringBoot (2.1.7) application with Hystrix (Javanica) and JCache (EHCache implementation). I have methods annotated with the @HystrixCommand annotation to enable Hystrix for them. I also have caching on those methods. It looks like this:

@Override
@HystrixCommand(fallbackMethod = "fallbackGetAllUserProfiles")
@Timed(histogram = true, percentiles = {0.75, 0.9, 0.95, 0.99})
@CacheResult
public UserProfiles getAllUserProfiles(@CacheKey String accountID, @CacheKey String userID) {
    return getAllUserProfilesFromBackend(accountID, userID);
}

UserProfiles getAllUserProfilesFromBackend(String accountID, String userID) {
   // call to backend; omitted for readability
}}

Now I am looking at the documentation and there are actually 2 different @CacheResult annotations: one from JCache (jsr-107) and one from Javanica (Hystrix).

If I also want Hystrix to use a cache, should I also specify the second @com.netflix.hystrix.contrib.javanica.cache.annotation.CacheResult?

Or can I better move the @CacheResult to the method getAllUserProfilesFromBackend and then annotate the Hystrix method with the Hystrix @CacheResult?

I am just wondering, as the Hystrix framework can use the cache in case of failing services, but it is not clear to me that it automatically uses JCache.

0

There are 0 best solutions below