Spring / Resilience4j Interview questions
What is the difference between the Resilience4j Cache module and a plain in-memory cache like Guava?
Guava's Cache is a general-purpose, standalone in-memory cache: you put and get arbitrary key-value pairs directly, with eviction policies like size limits or expiry, entirely independent of any resilience concerns.
Resilience4j's Cache module is narrower by design - it's a decorator specifically meant to wrap a function call, and it delegates the actual storage to a JSR-107 (JCache) provider rather than implementing its own cache engine, so it needs something like Ehcache configured underneath to actually hold data.
In practice, it's used to skip a whole resilience-wrapped call - dependency call plus CircuitBreaker plus Retry - entirely on a cache hit, whereas Guava's cache is typically reached for as general application-level caching unrelated to any specific fault-tolerance pipeline.
Because of this narrower scope and its dependency on an external JCache provider, many teams today favor Spring's own @Cacheable or a dedicated caching library for general use, and reserve Resilience4j's Cache specifically for cases where caching needs to sit directly inside an existing Decorators chain.
More Related questions...