feat(kol): cache marketplace and generation reads with singleflight

Add cache-aside + singleflight to KOL marketplace list/detail, my-subscription
prompts, and generation schema lookups. Invalidate the shared public-facing
caches when subscriptions are added/revoked (ops) or KOL profile is updated.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-24 11:33:17 +08:00
parent 09c8fe1e56
commit 8761e47f78
10 changed files with 339 additions and 102 deletions
@@ -36,7 +36,7 @@ type kolAssistStreamEvent struct {
}
func NewKolManageHandler(a *bootstrap.App, assets *AssetHandler) *KolManageHandler {
profileSvc := app.NewKolProfileService(a.KolProfiles).WithObjectStorage(a.ObjectStorage)
profileSvc := app.NewKolProfileService(a.KolProfiles).WithObjectStorage(a.ObjectStorage).WithCache(a.Cache)
return &KolManageHandler{
profileSvc: profileSvc,
@@ -18,7 +18,7 @@ type KolMarketplaceHandler struct {
func NewKolMarketplaceHandler(a *bootstrap.App) *KolMarketplaceHandler {
return &KolMarketplaceHandler{
svc: app.NewKolMarketplaceService(a.KolMarketplace, a.KolSubscriptions),
svc: app.NewKolMarketplaceService(a.KolMarketplace, a.KolSubscriptions).WithCache(a.Cache),
genSvc: app.NewKolGenerationService(
a.DB,
a.KolSubscriptions,