Documentation
¶
Overview ¶
Package list has some list cache implemented by redis
Index ¶
- Constants
- type BaseEntity
- type Cache
- func (p *Cache) Add(entity Entity) (bool, error)
- func (p *Cache) Del(ownerID string, targetID int64) (bool, error)
- func (p *Cache) GetCount(ownerID string) (count int64, err error)
- func (p *Cache) GetIDForOwnerTarget(ownerID string, targetID int64) (id int64, err error)
- func (p *Cache) LoadList(ownerID string, page, pageSize, cursor int64) (total int64, ids []int64, err error)
- func (p *Cache) LoadListWithScore(ownerID string, page, pageSize, cursor int64) (total int64, targetAndScores []*IDScore, err error)
- type CounterEntity
- type Entity
- type IDScore
Constants ¶
View Source
const (
MaxLoadBatch = 100
)
load const params
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BaseEntity ¶
type BaseEntity struct {
ID int64 `column:"id" pk:"Y"` //auto increment id
OwnerID string `column:"o_id"`
TargetID int64 `column:"t_id"`
CreateTime int64 `column:"ct"`
}
BaseEntity define the base list entity
func (*BaseEntity) GetCreateTime ¶
func (p *BaseEntity) GetCreateTime() int64
GetCreateTime impls Entity.GetCreateTime
func (*BaseEntity) GetOwnerID ¶
func (p *BaseEntity) GetOwnerID() string
GetOwnerID implement Entity.GetOwnerID
func (*BaseEntity) GetTargetID ¶
func (p *BaseEntity) GetTargetID() int64
GetTargetID implement Entity.GetTargetID()
func (*BaseEntity) SetCreateTime ¶
func (p *BaseEntity) SetCreateTime(ct int64)
SetCreateTime impls Entity.SetCreateTime
func (*BaseEntity) SetID ¶ added in v1.1.27
func (p *BaseEntity) SetID(id int64)
SetID implements Entity.GetID()
func (*BaseEntity) TableName ¶
func (p *BaseEntity) TableName() string
TableName implement Entity.TableName()
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache define the list cache
func NewCache ¶
func NewCache(entityProtoType Entity, dbService func() orm.ShardDBService, redisClient func() *cache.RedisClient, listCacheParam *cache.ParamConf, maxListCount int64, targetIDAsScore bool, counter counter.Counter) (*Cache, error)
NewCache create new Cache
func (*Cache) GetIDForOwnerTarget ¶
GetIDForOwnerTarget query the Entity.ID with ownerID and targetID
type CounterEntity ¶
type CounterEntity struct {
counter.BaseEntity
}
CounterEntity is the list counter
func (*CounterEntity) ToBaseEntity ¶
func (p *CounterEntity) ToBaseEntity(counterID string, fields counter.Fields) (*CounterEntity, error)
ToBaseEntity to base entity
func (*CounterEntity) ZeroFields ¶
func (p *CounterEntity) ZeroFields() counter.Fields
ZeroFields implements the EntityCounter.ZeroFields
type Entity ¶
type Entity interface {
orm.Entity
// GetID return the id
GetID() int64
// SetID
SetID(int64)
// GetOwnerID return the owner id
GetOwnerID() string
// GetTargetID return the target id
GetTargetID() int64
// GetCreateTime return create time
GetCreateTime() int64
// SetCreateTime set create time
SetCreateTime(ct int64)
}
Entity define the list entity interface
Click to show internal directories.
Click to hide internal directories.