(ctx context.Context, key string)
| 59 | } |
| 60 | |
| 61 | func (c *relationCache) GetCountCache(ctx context.Context, key string) (int64, error) { |
| 62 | count, err := c.client.Get(ctx, key).Int64() |
| 63 | if errors.Is(err, redis.Nil) { |
| 64 | return 0, nil // 缓存未命中 |
| 65 | } else if err != nil { |
| 66 | return 0, err // Redis调用失败 |
| 67 | } |
| 68 | |
| 69 | return count, nil |
| 70 | } |
| 71 | |
| 72 | func (c *relationCache) SetCountCache(ctx context.Context, key string, count int64, ttl time.Duration) error { |
| 73 | // 设置计数缓存并设置过期时间 |