(options ...interface{})
| 296 | } |
| 297 | |
| 298 | func (p *postRepository) refreshCache(options ...interface{}) { |
| 299 | payload := job.Payload{ |
| 300 | RefreshType: options[0].(int), |
| 301 | Key: options[1].(string), |
| 302 | } |
| 303 | |
| 304 | if len(options) > 2 { |
| 305 | payload.PostId = options[2].(uint) |
| 306 | } |
| 307 | |
| 308 | jsonPayload, err := json.Marshal(payload) |
| 309 | if err != nil { |
| 310 | p.l.Error("序列化任务负载失败", zap.Error(err)) |
| 311 | } |
| 312 | |
| 313 | task := asynq.NewTask(job.RefreshPostCache, jsonPayload) |
| 314 | if _, err := p.asynqClient.Enqueue(task, asynq.ProcessIn(time.Second*5)); err != nil { |
| 315 | p.l.Error("异步删除帖子缓存失败", zap.Error(err)) |
| 316 | } |
| 317 | } |
| 318 | |
| 319 | func (p *postRepository) GetPostsCount(ctx context.Context) (int64, error) { |
| 320 | return p.dao.GetPostsCount(ctx) |
no test coverage detected