IsEmpty 检查是否存在空对象标记
(ctx context.Context, key string)
| 118 | |
| 119 | // IsEmpty 检查是否存在空对象标记 |
| 120 | func (c *postCache) IsEmpty(ctx context.Context, key string) (bool, error) { |
| 121 | if key == "" { |
| 122 | return false, fmt.Errorf("无效的帖子ID: %s", key) |
| 123 | } |
| 124 | |
| 125 | exists, err := c.client.Exists(ctx, c.emptyKey(key)).Result() |
| 126 | if err != nil { |
| 127 | return false, err |
| 128 | } |
| 129 | |
| 130 | return exists > 0, nil |
| 131 | } |
| 132 | |
| 133 | // PreHeat 预热热点缓存,设置更长的过期时间 |
| 134 | func (c *postCache) PreHeat(ctx context.Context, posts []domain.Post) error { |