(ctx context.Context, followerID, followeeID int64)
| 75 | } |
| 76 | |
| 77 | func (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 | |
| 98 | func (c *relationCache) GenerateCacheKey(userID int64, relationType string, pagination domain.Pagination) string { |
| 99 | // 生成缓存键 |
nothing calls this directly
no test coverage detected