Package growthbook.sdk.java.remoteeval
Class RemoteEvalCache
java.lang.Object
growthbook.sdk.java.remoteeval.RemoteEvalCache
In-memory cache for remote-eval responses.
Backed by a Guava LoadingCache: served fresh within staleTtl, served stale
with a background refetch up to cacheTtl, refetched after that. Guava coalesces
concurrent reads for the same key into a single fetch.
-
Constructor Summary
ConstructorsConstructorDescriptionRemoteEvalCache(RemoteEvalService service, int maximumSize, Duration staleTtl, Duration cacheTtl) RemoteEvalCache(RemoteEvalService service, int maximumSize, Duration staleTtl, Duration cacheTtl, com.google.common.base.Ticker ticker) -
Method Summary
Modifier and TypeMethodDescriptionget(String cacheKey, RequestBodyForRemoteEval payload) voidvoidshutdown()
-
Constructor Details
-
RemoteEvalCache
public RemoteEvalCache(RemoteEvalService service, int maximumSize, @Nullable Duration staleTtl, @Nullable Duration cacheTtl) -
RemoteEvalCache
public RemoteEvalCache(RemoteEvalService service, int maximumSize, @Nullable Duration staleTtl, @Nullable Duration cacheTtl, @Nullable com.google.common.base.Ticker ticker) - Parameters:
service- performs the actual remote-eval POST.maximumSize- LRU bound on cached responses (values<= 0disable retention).staleTtl- when positive, enables stale-while-revalidate: entries older than this are served stale while refreshed in the background.nulldisables SWR.cacheTtl- when positive, the hard expiry after which an entry is dropped and refetched.nullmeans no time-based expiry (entries live until evicted or invalidated).ticker- time source;nulluses the system ticker. Injectable for tests.
-
-
Method Details
-
get
public RemoteEvalResponse get(String cacheKey, RequestBodyForRemoteEval payload) throws FeatureFetchException - Throws:
FeatureFetchException
-
invalidateAll
public void invalidateAll() -
shutdown
public void shutdown()
-