()
| 83 | } |
| 84 | |
| 85 | func (r *rankingLocalCache) validateCache() error { |
| 86 | if len(r.posts) == 0 { |
| 87 | r.logger.Warn("本地缓存为空") |
| 88 | return ErrCacheEmpty |
| 89 | } |
| 90 | |
| 91 | if time.Now().After(r.expireAt) { |
| 92 | r.logger.Warn("本地缓存已过期", |
| 93 | zap.Time("expire_at", r.expireAt)) |
| 94 | return ErrCacheExpired |
| 95 | } |
| 96 | |
| 97 | return nil |
| 98 | } |
| 99 | |
| 100 | func (r *rankingLocalCache) copyPosts() []domain.Post { |
| 101 | result := make([]domain.Post, len(r.posts)) |