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

Method SetCountCache

internal/repository/cache/check.go:156–162  ·  view source on GitHub ↗

SetCountCache 将审核记录的数量写入缓存

(ctx context.Context, key string, count int64, ttl time.Duration)

Source from the content-addressed store, hash-verified

154
155// SetCountCache 将审核记录的数量写入缓存
156func (c *checkCache) SetCountCache(ctx context.Context, key string, count int64, ttl time.Duration) error {
157 // 设置随机化的TTL,防止缓存雪崩
158 randomTTL := ttl + time.Duration(randomInt(0, 300))*time.Second
159
160 // 将计数数据写入Redis
161 return c.client.Set(ctx, key, count, randomTTL).Err()
162}
163
164// GenerateCacheKey 生成单个审核记录的缓存键
165func (c *checkCache) GenerateCacheKey(id interface{}) string {

Callers

nothing calls this directly

Calls 2

randomIntFunction · 0.85
SetMethod · 0.65

Tested by

no test coverage detected