Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrNotFound 数据未找到 ErrNotFound = errors.New("data not found") // ErrEmptyPlaceholder 数据为空 ErrEmptyPlaceholder = errors.New("empty placeholder") // ErrTimeout 超时 ErrTimeout = errors.New("timeout") // ErrResultIndexInvalid 无效索引 ErrResultIndexInvalid = errors.New("index out of range") // ErrResultIdNotFound ID 未找到 ErrResultIdNotFound = errors.New("id not found") // ErrIDCantBeNull ID 不可以为空 ErrIDCantBeNull = errors.New("id cant be null") )
Functions ¶
This section is empty.
Types ¶
type DeleteHandler ¶ added in v0.41.9
DeleteHandler 删除函数
type Entity ¶ added in v0.41.9
type Entity interface {
// Build 内部有一些处理
Build()
// Unmarshal 解码
Unmarshal(in []byte, out interface{}) error
// Get 根据主键获取数据
Get(out interface{}, id uint64) error
// GetWithQuery 根据主键获取数据
// query 自定义查询
GetWithQuery(out interface{}, id uint64, query QueryHandler) error
// MGet 根据主键批量获取数据
MGet(out interface{}, ids ...uint64) (*Result, error)
// Set 缓存数据
Set(in interface{}, id uint64) error
// Update 更新数据库,更新缓存
Update(model interface{}, id uint64) error
// Delete 删除数据库,删除缓存
Delete(model interface{}, id uint64) error
// MDelete 批量删除数据库,删除缓存
MDelete(model interface{}, ids ...uint64) error
// RemoveCache 仅删除缓存
RemoveCache(id uint64)
WithCodec(codec zerocodec.Codec) Entity
WithTimeout(timeout time.Duration) Entity
WithNotFoundExipred(expired time.Duration) Entity
WithReadDB(dbs ...WrapReadDB) Entity
WithWriteDB(db WrapWriteDB) Entity
WithLocalCache(localCache WrapCache) Entity
WithRemoteCache(remoteCache WrapCache) Entity
WithCustomQueryHandler(handler QueryHandler) Entity
WithCustomUpdateHandler(handler UpdateHandler) Entity
WithCustomDeleteHandler(handler DeleteHandler) Entity
}
Entity 实体
type QueryHandler ¶
QueryHandler 查询函数
type Stat ¶
type Stat struct {
Name string
// contains filtered or unexported fields
}
Stat 统计
func NewStat ¶
func NewStat(name string, handler StatHandler) *Stat
type StatHandler ¶ added in v0.41.9
type StatHandler func(localHit, localMiss, remoteHit, remoteMiss, dbFails, customFails uint64)
StatHandler 统计处理函数
type UpdateHandler ¶ added in v0.41.9
UpdateHandler 更新函数
type WrapCache ¶
type WrapCache interface {
Get(id uint64) ([]byte, error)
MGet(ids ...uint64) ([]*Value, error)
Set(id uint64, in []byte) error
MSet(ids []uint64, datas [][]byte) error
Delete(id uint64) error
MDelete(ids ...uint64) error
ErrNotFound() error
}
WrapCache 封装缓存
Click to show internal directories.
Click to hide internal directories.