cache.go 671 B

1234567891011121314151617181920212223242526
  1. package timemachine
  2. import (
  3. "context"
  4. "fmt"
  5. "go-common/app/interface/main/activity/model/timemachine"
  6. )
  7. func timemachineKey(mid int64) string {
  8. return fmt.Sprintf("tm_%d", mid)
  9. }
  10. //go:generate $GOPATH/src/go-common/app/tool/cache/gen
  11. type _cache interface {
  12. // cache
  13. Timemachine(c context.Context, mid int64) (*timemachine.Item, error)
  14. }
  15. //go:generate $GOPATH/src/go-common/app/tool/cache/mc
  16. type _mc interface {
  17. // mc: -key=timemachineKey -expire=d.mcTmExpire -encode=pb
  18. AddCacheTimemachine(c context.Context, mid int64, data *timemachine.Item) error
  19. // mc: -key=timemachineKey
  20. CacheTimemachine(c context.Context, mid int64) (*timemachine.Item, error)
  21. }