feat(kol): store KOL prompt content in database with object storage fallback
Add prompt_content columns to kol_prompts and kol_prompt_revisions so prompt bodies live alongside their metadata, eliminating an extra round trip to object storage for the common read path while keeping the old asset key as a fallback for legacy rows. Reads go through a singleflight-deduped, cache-backed loader that prefers the database column, falls back to the asset key, and tolerates missing objects via a new objectstorage.ErrObjectNotFound returned by both the Aliyun OSS and MinIO clients on 404/NoSuchKey responses. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -277,6 +277,10 @@ func kolPromptDetailCachePrefix(tenantID int64) string {
|
||||
return fmt.Sprintf("kol:prompt:detail:%d:", tenantID)
|
||||
}
|
||||
|
||||
func kolPromptContentCacheKey(tenantID, promptID int64) string {
|
||||
return fmt.Sprintf("kol:prompt:content:%d:%d", tenantID, promptID)
|
||||
}
|
||||
|
||||
func kolPromptListCachePrefix(tenantID int64) string {
|
||||
return fmt.Sprintf("kol:prompt:list:%d:", tenantID)
|
||||
}
|
||||
@@ -291,6 +295,7 @@ func kolSubscriptionPromptSchemaCachePrefix(tenantID int64) string {
|
||||
|
||||
func invalidateKolPromptCaches(ctx context.Context, c sharedcache.Cache, tenantID int64) {
|
||||
deleteCachePrefix(ctx, c, kolPromptDetailCachePrefix(tenantID))
|
||||
deleteCachePrefix(ctx, c, fmt.Sprintf("kol:prompt:content:%d:", tenantID))
|
||||
deleteCachePrefix(ctx, c, kolPromptListCachePrefix(tenantID))
|
||||
deleteCachePrefix(ctx, c, kolSubscriptionPromptListCachePrefix(tenantID))
|
||||
deleteCachePrefix(ctx, c, kolSubscriptionPromptSchemaCachePrefix(tenantID))
|
||||
@@ -299,6 +304,7 @@ func invalidateKolPromptCaches(ctx context.Context, c sharedcache.Cache, tenantI
|
||||
|
||||
func InvalidateKolPromptCaches(ctx context.Context, c sharedcache.Cache) {
|
||||
deleteCachePrefix(ctx, c, "kol:prompt:detail:")
|
||||
deleteCachePrefix(ctx, c, "kol:prompt:content:")
|
||||
deleteCachePrefix(ctx, c, "kol:prompt:list:")
|
||||
deleteCachePrefix(ctx, c, "kol:subscription_prompt:list:")
|
||||
deleteCachePrefix(ctx, c, "kol:subscription_prompt:schema:")
|
||||
|
||||
Reference in New Issue
Block a user