pull/410/head
小旭 5 years ago
parent e1ecc9fa5a
commit 3b510022a3
  1. 14
      tool/kratos-gen-bts/testdata/dao.bts.go
  2. 6
      tool/kratos-gen-bts/testdata/dao.go
  3. 12
      tool/kratos-gen-bts/testdata/multi.go
  4. 6
      tool/kratos-gen-bts/testdata/none.go
  5. 12
      tool/kratos-gen-bts/testdata/single.go

@ -27,12 +27,10 @@ import (
"github.com/bilibili/kratos/pkg/sync/errgroup" "github.com/bilibili/kratos/pkg/sync/errgroup"
) )
var ( var _ _bts
_ _bts
)
// Demos get data from cache if miss will call source method, then add to cache. // Demos get data from cache if miss will call source method, then add to cache.
func (d *Dao) Demos(c context.Context, keys []int64) (res map[int64]*Demo, err error) { func (d *dao) Demos(c context.Context, keys []int64) (res map[int64]*Demo, err error) {
if len(keys) == 0 { if len(keys) == 0 {
return return
} }
@ -111,7 +109,7 @@ func (d *Dao) Demos(c context.Context, keys []int64) (res map[int64]*Demo, err e
} }
// Demos1 get data from cache if miss will call source method, then add to cache. // Demos1 get data from cache if miss will call source method, then add to cache.
func (d *Dao) Demos1(c context.Context, keys []int64) (res map[int64]*Demo, err error) { func (d *dao) Demos1(c context.Context, keys []int64) (res map[int64]*Demo, err error) {
if len(keys) == 0 { if len(keys) == 0 {
return return
} }
@ -190,7 +188,7 @@ func (d *Dao) Demos1(c context.Context, keys []int64) (res map[int64]*Demo, err
} }
// Demo get data from cache if miss will call source method, then add to cache. // Demo get data from cache if miss will call source method, then add to cache.
func (d *Dao) Demo(c context.Context, key int64) (res *Demo, err error) { func (d *dao) Demo(c context.Context, key int64) (res *Demo, err error) {
addCache := true addCache := true
res, err = d.CacheDemo(c, key) res, err = d.CacheDemo(c, key)
if err != nil { if err != nil {
@ -223,7 +221,7 @@ func (d *Dao) Demo(c context.Context, key int64) (res *Demo, err error) {
} }
// Demo1 get data from cache if miss will call source method, then add to cache. // Demo1 get data from cache if miss will call source method, then add to cache.
func (d *Dao) Demo1(c context.Context, key int64, pn int, ps int) (res *Demo, err error) { func (d *dao) Demo1(c context.Context, key int64, pn int, ps int) (res *Demo, err error) {
addCache := true addCache := true
res, err = d.CacheDemo1(c, key, pn, ps) res, err = d.CacheDemo1(c, key, pn, ps)
if err != nil { if err != nil {
@ -250,7 +248,7 @@ func (d *Dao) Demo1(c context.Context, key int64, pn int, ps int) (res *Demo, er
} }
// None get data from cache if miss will call source method, then add to cache. // None get data from cache if miss will call source method, then add to cache.
func (d *Dao) None(c context.Context) (res *Demo, err error) { func (d *dao) None(c context.Context) (res *Demo, err error) {
addCache := true addCache := true
res, err = d.CacheNone(c) res, err = d.CacheNone(c)
if err != nil { if err != nil {

@ -13,13 +13,13 @@ type Demo struct {
} }
// Dao . // Dao .
type Dao struct { type dao struct {
cache *fanout.Fanout cache *fanout.Fanout
} }
// New . // New .
func New() *Dao { func New() *dao {
return &Dao{cache: fanout.New("cache")} return &dao{cache: fanout.New("cache")}
} }
//go:generate kratos tool genbts //go:generate kratos tool genbts

@ -12,37 +12,37 @@ var (
) )
// CacheDemos . // CacheDemos .
func (d *Dao) CacheDemos(c context.Context, keys []int64) (map[int64]*Demo, error) { func (d *dao) CacheDemos(c context.Context, keys []int64) (map[int64]*Demo, error) {
// get data from cache // get data from cache
return _multiCacheFunc(c, keys) return _multiCacheFunc(c, keys)
} }
// RawDemos . // RawDemos .
func (d *Dao) RawDemos(c context.Context, keys []int64) (map[int64]*Demo, error) { func (d *dao) RawDemos(c context.Context, keys []int64) (map[int64]*Demo, error) {
// get data from db // get data from db
return _multiRawFunc(c, keys) return _multiRawFunc(c, keys)
} }
// AddCacheDemos . // AddCacheDemos .
func (d *Dao) AddCacheDemos(c context.Context, values map[int64]*Demo) error { func (d *dao) AddCacheDemos(c context.Context, values map[int64]*Demo) error {
// add to cache // add to cache
return _multiAddCacheFunc(c, values) return _multiAddCacheFunc(c, values)
} }
// CacheDemos1 . // CacheDemos1 .
func (d *Dao) CacheDemos1(c context.Context, keys []int64) (map[int64]*Demo, error) { func (d *dao) CacheDemos1(c context.Context, keys []int64) (map[int64]*Demo, error) {
// get data from cache // get data from cache
return _multiCacheFunc(c, keys) return _multiCacheFunc(c, keys)
} }
// RawDemos . // RawDemos .
func (d *Dao) RawDemos1(c context.Context, keys []int64) (map[int64]*Demo, error) { func (d *dao) RawDemos1(c context.Context, keys []int64) (map[int64]*Demo, error) {
// get data from db // get data from db
return _multiRawFunc(c, keys) return _multiRawFunc(c, keys)
} }
// AddCacheDemos . // AddCacheDemos .
func (d *Dao) AddCacheDemos1(c context.Context, values map[int64]*Demo) error { func (d *dao) AddCacheDemos1(c context.Context, values map[int64]*Demo) error {
// add to cache // add to cache
return _multiAddCacheFunc(c, values) return _multiAddCacheFunc(c, values)
} }

@ -12,19 +12,19 @@ var (
) )
// CacheNone . // CacheNone .
func (d *Dao) CacheNone(c context.Context) (*Demo, error) { func (d *dao) CacheNone(c context.Context) (*Demo, error) {
// get data from cache // get data from cache
return _noneCacheFunc(c) return _noneCacheFunc(c)
} }
// RawNone . // RawNone .
func (d *Dao) RawNone(c context.Context) (*Demo, error) { func (d *dao) RawNone(c context.Context) (*Demo, error) {
// get data from db // get data from db
return _noneRawFunc(c) return _noneRawFunc(c)
} }
// AddCacheNone . // AddCacheNone .
func (d *Dao) AddCacheNone(c context.Context, value *Demo) error { func (d *dao) AddCacheNone(c context.Context, value *Demo) error {
// add to cache // add to cache
return _noneAddCacheFunc(c, value) return _noneAddCacheFunc(c, value)
} }

@ -12,37 +12,37 @@ var (
) )
// CacheDemo . // CacheDemo .
func (d *Dao) CacheDemo(c context.Context, key int64) (*Demo, error) { func (d *dao) CacheDemo(c context.Context, key int64) (*Demo, error) {
// get data from cache // get data from cache
return _singleCacheFunc(c, key) return _singleCacheFunc(c, key)
} }
// RawDemo . // RawDemo .
func (d *Dao) RawDemo(c context.Context, key int64) (*Demo, error) { func (d *dao) RawDemo(c context.Context, key int64) (*Demo, error) {
// get data from db // get data from db
return _singleRawFunc(c, key) return _singleRawFunc(c, key)
} }
// AddCacheDemo . // AddCacheDemo .
func (d *Dao) AddCacheDemo(c context.Context, key int64, value *Demo) error { func (d *dao) AddCacheDemo(c context.Context, key int64, value *Demo) error {
// add to cache // add to cache
return _singleAddCacheFunc(c, key, value) return _singleAddCacheFunc(c, key, value)
} }
// CacheDemo1 . // CacheDemo1 .
func (d *Dao) CacheDemo1(c context.Context, key int64, pn, ps int) (*Demo, error) { func (d *dao) CacheDemo1(c context.Context, key int64, pn, ps int) (*Demo, error) {
// get data from cache // get data from cache
return nil, nil return nil, nil
} }
// RawDemo1 . // RawDemo1 .
func (d *Dao) RawDemo1(c context.Context, key int64, pn, ps int) (*Demo, *Demo, error) { func (d *dao) RawDemo1(c context.Context, key int64, pn, ps int) (*Demo, *Demo, error) {
// get data from db // get data from db
return nil, nil, nil return nil, nil, nil
} }
// AddCacheDemo1 . // AddCacheDemo1 .
func (d *Dao) AddCacheDemo1(c context.Context, key int64, value *Demo, pn, ps int) error { func (d *dao) AddCacheDemo1(c context.Context, key int64, value *Demo, pn, ps int) error {
// add to cache // add to cache
return nil return nil
} }

Loading…
Cancel
Save