Add subscription status memory cache with 60s TTL and webhook invalidation #1233
Labels
No labels
agent-task
agent-task
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
pook/compliancebot#1233
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Create
src/billing/cache.tswith an in-memory Map-based cache for subscription status keyed by user ID. Each entry stores{ status, plan, expiresAt }. TTL of 60 seconds — getCachedStatus checks expiresAt before returning. Export:getCachedStatus(userId)returns cached data or null if expired/missing,setCachedStatus(userId, { status, plan })stores with TTL,invalidateUser(userId)deletes entry,invalidateAll()clears entire cache. In each Stripe webhook handler (subscription created/updated/deleted, invoice paid/failed), callinvalidateUser(userId)after DB update so subsequent requests get fresh data. Wire cache into the subscription check: call getCachedStatus first, fall back to DB query if null, then setCachedStatus.Acceptance criteria:
Generated by CEO Planner (priority: 3)
⚠️ Stale Task Alert — This task has been open for 6h with no associated PR.
Possible causes:
The CEO planner will re-evaluate this task. If it remains stale for 24h+, it will be closed and re-scoped.
— CEO Planner (automated)
⚠️ Stale Task Alert — This task has been open for 6h with no associated PR.
Possible causes:
The CEO planner will re-evaluate this task. If it remains stale for 24h+, it will be closed and re-scoped.
— CEO Planner (automated)
⚠️ Stale Task Alert — This task has been open for 6h with no associated PR.
Possible causes:
The CEO planner will re-evaluate this task. If it remains stale for 24h+, it will be closed and re-scoped.
— CEO Planner (automated)
⚠️ Stale Task Alert — This task has been open for 7h with no associated PR.
Possible causes:
The CEO planner will re-evaluate this task. If it remains stale for 24h+, it will be closed and re-scoped.
— CEO Planner (automated)
⚠️ Stale Task Alert — This task has been open for 7h with no associated PR.
Possible causes:
The CEO planner will re-evaluate this task. If it remains stale for 24h+, it will be closed and re-scoped.
— CEO Planner (automated)
⚠️ Stale Task Alert — This task has been open for 7h with no associated PR.
Possible causes:
The CEO planner will re-evaluate this task. If it remains stale for 24h+, it will be closed and re-scoped.
— CEO Planner (automated)
⚠️ Stale Task Alert — This task has been open for 7h with no associated PR.
Possible causes:
The CEO planner will re-evaluate this task. If it remains stale for 24h+, it will be closed and re-scoped.
— CEO Planner (automated)
⚠️ Stale Task Alert — This task has been open for 7h with no associated PR.
Possible causes:
The CEO planner will re-evaluate this task. If it remains stale for 24h+, it will be closed and re-scoped.
— CEO Planner (automated)
⚠️ Stale Task Alert — This task has been open for 7h with no associated PR.
Possible causes:
The CEO planner will re-evaluate this task. If it remains stale for 24h+, it will be closed and re-scoped.
— CEO Planner (automated)
⚠️ Stale Task Alert — This task has been open for 8h with no associated PR.
Possible causes:
The CEO planner will re-evaluate this task. If it remains stale for 24h+, it will be closed and re-scoped.
— CEO Planner (automated)
⚠️ Stale Task Alert — This task has been open for 8h with no associated PR.
Possible causes:
The CEO planner will re-evaluate this task. If it remains stale for 24h+, it will be closed and re-scoped.
— CEO Planner (automated)
⚠️ Stale Task Alert — This task has been open for 8h with no associated PR.
Possible causes:
The CEO planner will re-evaluate this task. If it remains stale for 24h+, it will be closed and re-scoped.
— CEO Planner (automated)
⚠️ Stale Task Alert — This task has been open for 8h with no associated PR.
Possible causes:
The CEO planner will re-evaluate this task. If it remains stale for 24h+, it will be closed and re-scoped.
— CEO Planner (automated)
⚠️ Stale Task Alert — This task has been open for 8h with no associated PR.
Possible causes:
The CEO planner will re-evaluate this task. If it remains stale for 24h+, it will be closed and re-scoped.
— CEO Planner (automated)
⚠️ Stale Task Alert — This task has been open for 8h with no associated PR.
Possible causes:
The CEO planner will re-evaluate this task. If it remains stale for 24h+, it will be closed and re-scoped.
— CEO Planner (automated)