(ctx context.Context, userID int64)
| 95 | } |
| 96 | |
| 97 | func (r *relationRepository) GetFolloweeCount(ctx context.Context, userID int64) (int64, error) { |
| 98 | cacheKey := r.cache.GenerateCountCacheKey(userID, "followees") |
| 99 | if cachedCount, err := r.cache.GetCountCache(ctx, cacheKey); err == nil { |
| 100 | r.logger.Info("Cache hit for followee count", zap.String("key", cacheKey)) |
| 101 | return cachedCount, nil |
| 102 | } |
| 103 | |
| 104 | count, err := r.dao.FollowCount(ctx, userID) |
| 105 | if err != nil { |
| 106 | return 0, err |
| 107 | } |
| 108 | |
| 109 | // 缓存关注数 |
| 110 | r.cache.SetCountCache(ctx, cacheKey, count.FolloweeCount, 5*time.Minute) |
| 111 | |
| 112 | return count.FolloweeCount, nil |
| 113 | } |
| 114 | |
| 115 | func (r *relationRepository) GetFollowerCount(ctx context.Context, userID int64) (int64, error) { |
| 116 | cacheKey := r.cache.GenerateCountCacheKey(userID, "followers") |
nothing calls this directly
no test coverage detected