Skip to content

perf(server): invalidate planStats cache on node link/unlink#17

Open
Sentinel-Bluebuilder wants to merge 1 commit into
masterfrom
feat/server-planstats-invalidation
Open

perf(server): invalidate planStats cache on node link/unlink#17
Sentinel-Bluebuilder wants to merge 1 commit into
masterfrom
feat/server-planstats-invalidation

Conversation

@Sentinel-Bluebuilder

Copy link
Copy Markdown
Owner

What

getPlanStats caches planStats:<planId>:<operator> for 120s — this is what drives the totalNodes / totalSubscriptions counts on the plan card. After a link/unlink the cached count stayed stale for the full TTL, so the card never reflected the just-added (or removed) node until the cache expired.

Fix

Add invalidatePlanStats(planId) and call it on every success path of the four node-mutation routes:

Route Success paths invalidated
POST /api/plan-manager/link link-only retry + bundled lease+link
POST /api/plan-manager/batch-link links-only retry + bundled
POST /api/plan-manager/unlink unlink success
POST /api/plan-manager/batch-unlink batch-unlink success

cacheInvalidate is an EXACT-key delete, and each route already knows both planId and getAddr(), so the operator-scoped key is reconstructed directly — no prefix tracking needed. The next /api/my-plans re-queries chain truth.

Notes

PR series

Fifth of the working-tree split: #13 (audit), #14 (plan-nodes cache), #15 (FE reconcile), #16 (gas/sessions cache), this (planStats invalidation).

getPlanStats caches `planStats:<planId>:<operator>` for 120s — this drives
the totalNodes / totalSubscriptions counts on the plan card. After a
link/unlink the cached count stayed stale for the full TTL, so the card
never reflected the just-added (or removed) node until the cache expired.

Add invalidatePlanStats(planId) and call it on every success path of the
four node-mutation routes:
- link (link-only retry + bundled lease+link)
- batch-link (links-only retry + bundled)
- unlink
- batch-unlink

cacheInvalidate is an EXACT-key delete and each route already knows both
planId and getAddr(), so the operator-scoped key is reconstructed directly
with no prefix tracking. The next /api/my-plans re-queries chain truth.
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.

1 participant