MCPcopy Create free account
hub / github.com/GoSimplicity/LinkMe / refreshAllCache

Method refreshAllCache

internal/job/refresh_cache.go:101–131  ·  view source on GitHub ↗

刷新所有类型缓存

(ctx context.Context, key, postId string, logger *zap.Logger)

Source from the content-addressed store, hash-verified

99
100// 刷新所有类型缓存
101func (r *RefreshCacheTask) refreshAllCache(ctx context.Context, key, postId string, logger *zap.Logger) error {
102 var errs []error
103
104 if err := r.cache.DelList(ctx, key); err != nil {
105 logger.Error("删除普通帖子列表缓存失败", zap.Error(err))
106 errs = append(errs, fmt.Errorf("删除普通帖子列表缓存失败: %w", err))
107 }
108
109 if err := r.cache.Del(ctx, postId); err != nil {
110 logger.Error("删除普通帖子缓存失败", zap.Error(err))
111 errs = append(errs, fmt.Errorf("删除普通帖子缓存失败: %w", err))
112 }
113
114 if err := r.cache.DelPub(ctx, postId); err != nil {
115 logger.Error("删除发布帖子缓存失败", zap.Error(err))
116 errs = append(errs, fmt.Errorf("删除发布帖子缓存失败: %w", err))
117 }
118
119 if err := r.cache.DelPubList(ctx, key); err != nil {
120 logger.Error("删除发布帖子列表缓存失败", zap.Error(err))
121 errs = append(errs, fmt.Errorf("删除发布帖子列表缓存失败: %w", err))
122 }
123
124 if len(errs) > 0 {
125 logger.Warn("部分缓存删除失败", zap.Int("error_count", len(errs)))
126 return fmt.Errorf("部分缓存删除失败: %v", errs)
127 }
128
129 logger.Info("所有缓存删除成功")
130 return nil
131}

Callers 1

ProcessTaskMethod · 0.95

Calls 4

DelListMethod · 0.65
DelMethod · 0.65
DelPubMethod · 0.65
DelPubListMethod · 0.65

Tested by

no test coverage detected