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

Method refreshCache

internal/repository/post.go:298–317  ·  view source on GitHub ↗
(options ...interface{})

Source from the content-addressed store, hash-verified

296}
297
298func (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
319func (p *postRepository) GetPostsCount(ctx context.Context) (int64, error) {
320 return p.dao.GetPostsCount(ctx)

Callers 4

CreateMethod · 0.95
UpdateMethod · 0.95
UpdateStatusMethod · 0.95
DeleteMethod · 0.95

Calls 1

EnqueueMethod · 0.80

Tested by

no test coverage detected