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

Method ClearFollowCache

internal/repository/cache/relation.go:77–96  ·  view source on GitHub ↗
(ctx context.Context, followerID, followeeID int64)

Source from the content-addressed store, hash-verified

75}
76
77func (c *relationCache) ClearFollowCache(ctx context.Context, followerID, followeeID int64) error {
78 // 批量删除相关缓存
79 keys := []string{
80 c.GenerateCacheKey(followerID, "followers", domain.Pagination{}),
81 c.GenerateCacheKey(followeeID, "followees", domain.Pagination{}),
82 c.GenerateCountCacheKey(followerID, "followers"),
83 c.GenerateCountCacheKey(followeeID, "followees"),
84 }
85
86 // 使用Pipeline进行批量删除
87 pipe := c.client.Pipeline()
88
89 for _, key := range keys {
90 pipe.Del(ctx, key)
91 }
92
93 _, err := pipe.Exec(ctx)
94
95 return err
96}
97
98func (c *relationCache) GenerateCacheKey(userID int64, relationType string, pagination domain.Pagination) string {
99 // 生成缓存键

Callers

nothing calls this directly

Calls 4

GenerateCacheKeyMethod · 0.95
GenerateCountCacheKeyMethod · 0.95
DelMethod · 0.65
ExecMethod · 0.65

Tested by

no test coverage detected