Class RemoteEvalCache

java.lang.Object
growthbook.sdk.java.remoteeval.RemoteEvalCache

public final class RemoteEvalCache extends Object
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 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 <= 0 disable retention).
      staleTtl - when positive, enables stale-while-revalidate: entries older than this are served stale while refreshed in the background. null disables SWR.
      cacheTtl - when positive, the hard expiry after which an entry is dropped and refetched. null means no time-based expiry (entries live until evicted or invalidated).
      ticker - time source; null uses the system ticker. Injectable for tests.
  • Method Details