Documentation ¶ Index ¶ type Repo func (r *Repo) Close() error func (r *Repo) DelCache(ctx context.Context, key string) func (r *Repo) GetCache() cache.Cache func (r *Repo) GetDB() *gorm.DB func (r *Repo) QueryCache(ctx context.Context, key string, data any, ttl time.Duration, ...) (err error) Constants ¶ This section is empty. Variables ¶ This section is empty. Functions ¶ This section is empty. Types ¶ type Repo ¶ type Repo struct { DB *gorm.DB Cache cache.Cache } Repo struct func (*Repo) Close ¶ func (r *Repo) Close() error Close mysql connection func (*Repo) DelCache ¶ func (r *Repo) DelCache(ctx context.Context, key string) DelCache 删除缓存 func (*Repo) GetCache ¶ func (r *Repo) GetCache() cache.Cache GetCache 获取 cache func (*Repo) GetDB ¶ func (r *Repo) GetDB() *gorm.DB GetDB 获取 gorm.DB func (*Repo) QueryCache ¶ func (r *Repo) QueryCache(ctx context.Context, key string, data any, ttl time.Duration, query func(any) error) (err error) QueryCache 查询启用缓存 缓存的更新策略使用 Cache Aside Pattern see: https://coolshell.cn/articles/17416.html Source Files ¶ View all Source files repo.go Click to show internal directories. Click to hide internal directories.