feat: scope articles by brand
This commit is contained in:
@@ -52,12 +52,20 @@ func deleteCachePrefix(ctx context.Context, c sharedcache.Cache, prefix string)
|
||||
_ = c.DeletePrefix(ctx, prefix)
|
||||
}
|
||||
|
||||
func workspaceOverviewCacheKey(tenantID int64) string {
|
||||
return fmt.Sprintf("workspace:overview:%d", tenantID)
|
||||
func workspaceOverviewCachePrefix(tenantID int64) string {
|
||||
return fmt.Sprintf("workspace:overview:%d:", tenantID)
|
||||
}
|
||||
|
||||
func workspaceRecentArticlesCacheKey(tenantID int64) string {
|
||||
return fmt.Sprintf("workspace:recent_articles:%d", tenantID)
|
||||
func workspaceOverviewCacheKey(tenantID, brandID int64) string {
|
||||
return fmt.Sprintf("%s%d", workspaceOverviewCachePrefix(tenantID), brandID)
|
||||
}
|
||||
|
||||
func workspaceRecentArticlesCachePrefix(tenantID int64) string {
|
||||
return fmt.Sprintf("workspace:recent_articles:%d:", tenantID)
|
||||
}
|
||||
|
||||
func workspaceRecentArticlesCacheKey(tenantID, brandID int64) string {
|
||||
return fmt.Sprintf("%s%d", workspaceRecentArticlesCachePrefix(tenantID), brandID)
|
||||
}
|
||||
|
||||
func workspaceQuotaSummaryCacheKey(tenantID int64) string {
|
||||
@@ -73,8 +81,8 @@ func workspaceKolCardsCacheKey(tenantID int64) string {
|
||||
}
|
||||
|
||||
func invalidateWorkspaceCaches(ctx context.Context, c sharedcache.Cache, tenantID int64) {
|
||||
deleteCacheKey(ctx, c, workspaceOverviewCacheKey(tenantID))
|
||||
deleteCacheKey(ctx, c, workspaceRecentArticlesCacheKey(tenantID))
|
||||
deleteCachePrefix(ctx, c, workspaceOverviewCachePrefix(tenantID))
|
||||
deleteCachePrefix(ctx, c, workspaceRecentArticlesCachePrefix(tenantID))
|
||||
deleteCacheKey(ctx, c, workspaceQuotaSummaryCacheKey(tenantID))
|
||||
deleteCacheKey(ctx, c, workspaceTemplateCardsCacheKey(tenantID))
|
||||
deleteCacheKey(ctx, c, workspaceKolCardsCacheKey(tenantID))
|
||||
@@ -186,21 +194,17 @@ func invalidatePromptRuleCaches(ctx context.Context, c sharedcache.Cache, tenant
|
||||
deleteCachePrefix(ctx, c, articleListCachePrefix(tenantID))
|
||||
}
|
||||
|
||||
func scheduleTaskDetailCacheKey(tenantID, taskID int64) string {
|
||||
return fmt.Sprintf("%s%d", scheduleTaskDetailCachePrefix(tenantID), taskID)
|
||||
func scheduleTaskDetailCacheKey(tenantID, brandID, taskID int64) string {
|
||||
return fmt.Sprintf("%s%d:%d", scheduleTaskDetailCachePrefix(tenantID), brandID, taskID)
|
||||
}
|
||||
|
||||
func scheduleTaskListCacheKey(tenantID int64, params interface{}) string {
|
||||
return scheduleTaskListCachePrefix(tenantID) + digestCacheKey(params)
|
||||
func scheduleTaskListCacheKey(tenantID, brandID int64, params interface{}) string {
|
||||
return fmt.Sprintf("%s%d:%s", scheduleTaskListCachePrefix(tenantID), brandID, digestCacheKey(params))
|
||||
}
|
||||
|
||||
func invalidateScheduleTaskCaches(ctx context.Context, c sharedcache.Cache, tenantID int64, taskID *int64) {
|
||||
deleteCachePrefix(ctx, c, scheduleTaskListCachePrefix(tenantID))
|
||||
if taskID != nil && *taskID > 0 {
|
||||
deleteCacheKey(ctx, c, scheduleTaskDetailCacheKey(tenantID, *taskID))
|
||||
} else {
|
||||
deleteCachePrefix(ctx, c, scheduleTaskDetailCachePrefix(tenantID))
|
||||
}
|
||||
deleteCachePrefix(ctx, c, scheduleTaskDetailCachePrefix(tenantID))
|
||||
}
|
||||
|
||||
func InvalidateScheduleTaskCaches(ctx context.Context, c sharedcache.Cache, tenantID int64, taskID *int64) {
|
||||
|
||||
Reference in New Issue
Block a user