Documentation ¶
Index ¶
- type CacherOption
- type ICacher
- type IGen
- type Locker
- type TurnCacher
- func (t *TurnCacher) GetCacherKey() string
- func (t *TurnCacher) GetOnly(ctx context.Context, turn int) (interface{}, error)
- func (t *TurnCacher) GetOrGen(ctx context.Context, turn int) (interface{}, error)
- func (t *TurnCacher) GetTurnKey(turn int) string
- func (t *TurnCacher) PopOrGen(ctx context.Context, turn int) (interface{}, error)
- func (t *TurnCacher) Start()
- func (t *TurnCacher) Stop()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CacherOption ¶
type CacherOption func(*TurnCacher)
func OptGapTime ¶
func OptGapTime(gapTime time.Duration) CacherOption
func OptGapTurn ¶
func OptGapTurn(gapTurn int) CacherOption
func OptKeyPrefix ¶
func OptKeyPrefix(prefix string) CacherOption
func OptLocker ¶
func OptLocker(locker Locker) CacherOption
func OptResetTurnIfNotFound ¶
func OptResetTurnIfNotFound() CacherOption
type ICacher ¶
type ICacher interface { Load(ctx context.Context, turn int, pop bool) (interface{}, error) // load result of turn X (own db) Save(ctx context.Context, turn int, value interface{}) error // save result of turn Y (own db) GetCacher(ctx context.Context) (int, error) // get current cached turn (own db) SetCacher(ctx context.Context, turn int) error // save current cached turn (own db) }
type TurnCacher ¶
type TurnCacher struct {
// contains filtered or unexported fields
}
functask: slowly warm up first
func NewTurnCacher ¶
func NewTurnCacher(name string, cacher ICacher, gentor IGen, opts ...CacherOption) *TurnCacher
func (*TurnCacher) GetCacherKey ¶
func (t *TurnCacher) GetCacherKey() string
func (*TurnCacher) GetOnly ¶
func (t *TurnCacher) GetOnly(ctx context.Context, turn int) (interface{}, error)
func (*TurnCacher) GetOrGen ¶
func (t *TurnCacher) GetOrGen(ctx context.Context, turn int) (interface{}, error)
-- get
func (*TurnCacher) PopOrGen ¶
func (t *TurnCacher) PopOrGen(ctx context.Context, turn int) (interface{}, error)
func (*TurnCacher) Stop ¶
func (t *TurnCacher) Stop()
Click to show internal directories.
Click to hide internal directories.