dao.go 872 B

1234567891011121314151617181920212223242526272829303132333435
  1. package testdata
  2. import (
  3. "context"
  4. "go-common/library/sync/pipeline/fanout"
  5. )
  6. // Article test struct
  7. type Article struct {
  8. ID int64
  9. Title string
  10. }
  11. // Dao .
  12. type Dao struct {
  13. cache *fanout.Fanout
  14. }
  15. // New .
  16. func New() *Dao {
  17. return &Dao{cache: fanout.New("cache")}
  18. }
  19. //go:generate $GOPATH/src/go-common/app/tool/cache/gen
  20. type _cache interface {
  21. // cache: -batch=10 -max_group=10 -batch_err=break -nullcache=&Article{ID:-1} -check_null_code=$.ID==-1
  22. Articles(c context.Context, keys []int64) (map[int64]*Article, error)
  23. // cache: -sync=true -nullcache=&Article{ID:-1} -check_null_code=$.ID==-1
  24. Article(c context.Context, key int64) (*Article, error)
  25. // cache: -paging=true
  26. Article1(c context.Context, key int64, pn, ps int) (*Article, error)
  27. // cache: -nullcache=&Article{ID:-1} -check_null_code=$.ID==-1
  28. None(c context.Context) (*Article, error)
  29. }