cache.go 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. package dao
  2. import (
  3. "context"
  4. "go-common/app/interface/main/space/model"
  5. )
  6. //go:generate $GOPATH/src/go-common/app/tool/cache/gen
  7. type _cache interface {
  8. // cache: -nullcache=&model.Notice{Notice:"ff2364a0be3d20e46cc69efb36afe9a5"} -check_null_code=$.Notice=="ff2364a0be3d20e46cc69efb36afe9a5"
  9. Notice(c context.Context, mid int64) (*model.Notice, error)
  10. // cache: -nullcache=&model.AidReason{Aid:-1} -check_null_code=$!=nil&&$.Aid==-1
  11. TopArc(c context.Context, mid int64) (*model.AidReason, error)
  12. // cache: -nullcache=&model.AidReasons{List:[]*model.AidReason{{Aid:-1}}} -check_null_code=len($.List)==1&&$.List[0].Aid==-1
  13. Masterpiece(c context.Context, mid int64) (*model.AidReasons, error)
  14. // cache: -nullcache=&model.ThemeDetails{List:[]*model.ThemeDetail{{ID:-1}}} -check_null_code=len($.List)==1&&$.List[0].ID==-1
  15. Theme(c context.Context, mid int64) (*model.ThemeDetails, error)
  16. // cache: -nullcache=-1 -check_null_code=$==-1
  17. TopDynamic(c context.Context, mid int64) (int64, error)
  18. }
  19. //go:generate $GOPATH/src/go-common/app/tool/cache/mc
  20. type _mc interface {
  21. // get notice data from mc cache.
  22. // mc: -key=noticeKey
  23. CacheNotice(c context.Context, mid int64) (*model.Notice, error)
  24. // set notice data to mc cache.
  25. // mc: -key=noticeKey -expire=d.mcNoticeExpire -encode=pb
  26. AddCacheNotice(c context.Context, mid int64, data *model.Notice) error
  27. // mc: -key=noticeKey
  28. DelCacheNotice(c context.Context, mid int64) error
  29. // get top archive data from mc cache.
  30. // mc: -key=topArcKey
  31. CacheTopArc(c context.Context, mid int64) (*model.AidReason, error)
  32. // set top archive data to mc cache.
  33. // mc: -key=topArcKey -expire=d.mcTopArcExpire -encode=pb
  34. AddCacheTopArc(c context.Context, mid int64, data *model.AidReason) error
  35. // get top archive data from mc cache.
  36. // mc: -key=masterpieceKey
  37. CacheMasterpiece(c context.Context, mid int64) (*model.AidReasons, error)
  38. // set top archive data to mc cache.
  39. // mc: -key=masterpieceKey -expire=d.mcMpExpire -encode=pb
  40. AddCacheMasterpiece(c context.Context, mid int64, data *model.AidReasons) error
  41. // get theme data from mc cache.
  42. // mc: -key=themeKey
  43. CacheTheme(c context.Context, mid int64) (*model.ThemeDetails, error)
  44. // set theme data to mc cache.
  45. // mc: -key=themeKey -expire=d.mcThemeExpire -encode=pb
  46. AddCacheTheme(c context.Context, mid int64, data *model.ThemeDetails) error
  47. // mc: -key=themeKey
  48. DelCacheTheme(c context.Context, mid int64) error
  49. // get top dynamic id cache.
  50. // mc: -key=topDyKey
  51. CacheTopDynamic(c context.Context, key int64) (int64, error)
  52. // set top dynamic id cache.
  53. // mc: -key=topDyKey -expire=d.mcTopDyExpire -encode=raw
  54. AddCacheTopDynamic(c context.Context, key int64, value int64) error
  55. }