Skip to content

[ING-483] misc(cache): Stop eager charge cache expiration - #5977

Merged
vincent-pochet merged 1 commit into
mainfrom
misc-lazy-cache
Sep 14, 2026
Merged

vincent-pochet merged 1 commit into
mainfrom
misc-lazy-cache

Conversation

@vincent-pochet

Copy link
Copy Markdown
Collaborator

Context

Related to #5959 & getlago/lago#766

Decription

This PR removes the charge cache invalidation logic from the events-processor, as we are now relying on a lazy invalidation approach.

@vincent-pochet
vincent-pochet force-pushed the misc-lazy-cache branch 2 times, most recently from 54f28be to e5cb2a7 Compare July 21, 2026 07:32
@lago-claude-ai-agent

Copy link
Copy Markdown
Contributor

Automated pre-review (advisory, not a required check) — verdict: HOLD · CI green

HOLD — Remove lazy_charge_usage_cache from app/config/feature_flags.yaml and regenerate schema.graphql and schema.json. The patch makes the flag a no-op but still exposes it as a valid, configurable GraphQL feature flag.

## Context

The charge usage cache used to be expired eagerly, from the event
post-processing path, on every event reception. Lazy validation, gated
behind the `lazy_charge_usage_cache` feature flag, replaced it: the cache
entry carries the watermark of what it aggregated and is rejected at read
time when a newer event exists.

## Description

Remove the eager expiration and stop reading the feature flag that
selected between the two strategies, so lazy validation is the only
behaviour. The cache key version is now `2` for every organization, which
drops the entries written under the legacy shape instead of reading them
back with the wrong value shape.

Full usage entries and the ingestion timestamps that feed them are no
longer conditioned on the flag either: they now depend only on the
granular lifetime usage integration and on the request being describable
by the cache key.

The flag itself is kept declared for now, and will be retired in a
follow-up once no organization carries it any more.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@lago-claude-ai-agent

Copy link
Copy Markdown
Contributor

Automated pre-review (advisory, not a required check) — verdict: PASS · CI green

PASS — Lazy charge-cache validation is consistently enabled across cache keys, readers, and full-usage caching. Explicit invalidation remains for usage-removal paths, and the specs cover wrapped-cache invalidation and full-usage caching without the feature flag.

@vincent-pochet
vincent-pochet merged commit 9accc04 into main Sep 14, 2026
12 checks passed
@vincent-pochet
vincent-pochet deleted the misc-lazy-cache branch September 14, 2026 07:48
vincent-pochet added a commit that referenced this pull request Sep 14, 2026
> Follow-up of #5977, which removed the last reader of the flag.

## Context

Nothing reads the `lazy_charge_usage_cache` feature flag anymore: lazy
validation of the charge
usage cache is now unconditional, and the eager expiration path it used
to gate is gone. Unlike the
other flags removed recently, this one was enabled on real
organizations, so the value still sits in
their `organizations.feature_flags`.

## Description

- Remove the `lazy_charge_usage_cache` flag definition.
- Regenerate the GraphQL schema dumps, since `FeatureFlagEnum` is built
from the flag definitions.

A stale value is harmless — `feature_flag_enabled?` is never called with
it and the GraphQL type
filters out unknown flags — but `FeatureFlag.sanitize!` can be run after
deploy to clear it.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants