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

Method GetFolloweeCount

internal/repository/relation.go:97–113  ·  view source on GitHub ↗
(ctx context.Context, userID int64)

Source from the content-addressed store, hash-verified

95}
96
97func (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
115func (r *relationRepository) GetFollowerCount(ctx context.Context, userID int64) (int64, error) {
116 cacheKey := r.cache.GenerateCountCacheKey(userID, "followers")

Callers

nothing calls this directly

Calls 4

GenerateCountCacheKeyMethod · 0.65
GetCountCacheMethod · 0.65
FollowCountMethod · 0.65
SetCountCacheMethod · 0.65

Tested by

no test coverage detected