Documentation
¶
Index ¶
- type AtomicBool
- 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) Get(key any) any
- func (c *LocalCache) Remove(key any)
- func (c *LocalCache) Set(key any, value any, d time.Duration)
- func (c *LocalCache) Size() int
- func (c *LocalCache) StopLaterUpdate(key any)
- func (c *LocalCache) UpdateLater(key any, d time.Duration, getValueFunc GetValueFunc)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AtomicBool ¶
type AtomicBool struct {
// contains filtered or unexported fields
}
atomicBool is a wrapper around uint32 for usage as a boolean value with atomic access.
func NewAtomicBool ¶
func NewAtomicBool(flag bool) *AtomicBool
func (*AtomicBool) IsSet ¶
func (ab *AtomicBool) IsSet() bool
IsSet returns whether the current boolean value is true
func (*AtomicBool) IsTrue ¶
func (ab *AtomicBool) IsTrue() bool
func (*AtomicBool) Set ¶
func (ab *AtomicBool) Set(value bool)
Set sets the value of the bool regardless of the previous value
type CalcTimeForNextUpdateFunc ¶ added in v0.0.2
Calculate the waiting time until the next data update
type GetValueFunc ¶
type GetValueFunc func() any
type LocalCache ¶
type LocalCache struct {
// contains filtered or unexported fields
}
func NewCache ¶
func NewCache(waitUpdate bool) *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)
1. Calculate the waiting time until the next data update with CalcTimeForNextUpdateFunc 2. then use GetValueFunc to get value 3. update item
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) Size ¶ added in v0.0.2
func (c *LocalCache) Size() int
func (*LocalCache) StopLaterUpdate ¶ added in v0.0.2
func (c *LocalCache) StopLaterUpdate(key any)
func (*LocalCache) UpdateLater ¶ added in v0.0.2
func (c *LocalCache) UpdateLater(key any, d time.Duration, getValueFunc GetValueFunc)
1. wait d 2. then use GetValueFunc to get value 3. update item
Click to show internal directories.
Click to hide internal directories.