mirror of
https://github.com/QuantumNous/new-api.git
synced 2026-04-18 18:07:28 +00:00
✨ feat(subscription): cache plan lookups and stabilize pre-consume
Introduce hybrid caches for subscription plans, items, and plan info with explicit invalidation on admin updates. Streamline pre-consume transactions to reduce redundant queries while preserving idempotency and reset logic.
This commit is contained in:
@@ -192,6 +192,7 @@ func AdminCreateSubscriptionPlan(c *gin.Context) {
|
||||
common.ApiError(c, err)
|
||||
return
|
||||
}
|
||||
model.InvalidateSubscriptionPlanCache(req.Plan.Id)
|
||||
common.ApiSuccess(c, req.Plan)
|
||||
}
|
||||
|
||||
@@ -275,6 +276,7 @@ func AdminUpdateSubscriptionPlan(c *gin.Context) {
|
||||
common.ApiError(c, err)
|
||||
return
|
||||
}
|
||||
model.InvalidateSubscriptionPlanCache(id)
|
||||
common.ApiSuccess(c, nil)
|
||||
}
|
||||
|
||||
@@ -289,6 +291,7 @@ func AdminDeleteSubscriptionPlan(c *gin.Context) {
|
||||
common.ApiError(c, err)
|
||||
return
|
||||
}
|
||||
model.InvalidateSubscriptionPlanCache(id)
|
||||
common.ApiSuccess(c, nil)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user