Skip to content

feat(perf): evaluation caching (Caffeine) + ETag/304 on SDK endpoint #30

Description

@trinhvandat

Context (P1 — scale)

Every SDK GET /api/v1/sdk/flags call hits PostgreSQL. Polling SDK fleets multiply this. Redis is on the v2 roadmap; Caffeine covers single-instance now.

Scope

  • Caffeine cache keyed by environment id over the evaluation response; invalidate on flag/flag-state/flag-archive mutations (and on flag creation which fans out states)
  • ETag (hash of payload or env-version counter) + If-None-Match → 304 handling on the SDK endpoint
  • Cache metrics via Micrometer (hit ratio)
  • Config: TTL + max size in properties

Acceptance criteria

  • Repeated evaluation calls do not hit the DB (verify via query counter or datasource-proxy in test)
  • Any admin mutation to a flag/state invalidates that environment's entry (integration test)
  • Clients sending If-None-Match get 304 with empty body

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions