Documentation
¶
Index ¶
- type CalcTimeForNextUpdateFunc
- type GetValueFunc
- type Item
- type LocalCache
- func (c *LocalCache) Contains(key any) (ok bool)
- func (c *LocalCache) DynamicUpdateLater(key any, cf CalcTimeForNextUpdateFunc, gf GetValueFunc)
- func (c *LocalCache) FirstLoad(key any, defaultValue any, gf GetValueFunc, d time.Duration) any
- func (c *LocalCache) Get(key any) any
- func (c *LocalCache) Remove(key any)
- func (c *LocalCache) Set(key any, value any, d time.Duration)
- func (c *LocalCache) SetIfNotExist(key any, value any, d time.Duration)
- func (c *LocalCache) Size() int
- func (c *LocalCache) Stop()
- func (c *LocalCache) StopLaterUpdate(key any)
- type Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CalcTimeForNextUpdateFunc ¶ added in v0.0.2
Calculate the waiting time until the next data update
type GetValueFunc ¶
type LocalCache ¶
type LocalCache struct {
// contains filtered or unexported fields
}
func NewCache ¶
func NewCache(waitUpdate bool, opts ...Option) *LocalCache
func (*LocalCache) Contains ¶ added in v0.0.3
func (c *LocalCache) Contains(key any) (ok bool)
func (*LocalCache) DynamicUpdateLater ¶ added in v0.0.2
func (c *LocalCache) DynamicUpdateLater(key any, cf CalcTimeForNextUpdateFunc, gf GetValueFunc)
Notice: Item and CalcTimeForNextUpdateFunc, GetValueFunc will only be bound once. 1. Calculate the waiting time until the next data update with CalcTimeForNextUpdateFunc 2. then use GetValueFunc to get value 3. update item
func (*LocalCache) FirstLoad ¶ added in v0.0.7
func (c *LocalCache) FirstLoad(key any, defaultValue any, gf GetValueFunc, d time.Duration) any
func (*LocalCache) Get ¶
func (c *LocalCache) Get(key any) any
func (*LocalCache) Remove ¶ added in v0.0.2
func (c *LocalCache) Remove(key any)
func (*LocalCache) Set ¶
func (c *LocalCache) Set(key any, value any, d time.Duration)
If d is less than 0, the item does not expire
func (*LocalCache) SetIfNotExist ¶ added in v0.0.7
func (c *LocalCache) SetIfNotExist(key any, value any, d time.Duration)
If d is less than 0, the item does not expire
func (*LocalCache) Size ¶ added in v0.0.2
func (c *LocalCache) Size() int
func (*LocalCache) Stop ¶ added in v0.1.1
func (c *LocalCache) Stop()
func (*LocalCache) StopLaterUpdate ¶ added in v0.0.2
func (c *LocalCache) StopLaterUpdate(key any)
type Option ¶ added in v0.0.9
type Option func(cache *LocalCache)
func WithRateLimit ¶ added in v0.0.9
WithRateLimit create a new Limiter that allows events up to rate r and permits bursts of at most b tokens. rate limiter Limit the execution frequency of GetValueFunc
Click to show internal directories.
Click to hide internal directories.