Documentation ¶
Index ¶
- func NewPeerTimeCache(timeCache types.TimeCacher) (*peerTimeCache, error)
- func NewTimeCacher(arg ArgTimeCacher) (*timeCacher, error)
- type ArgTimeCacher
- type TimeCache
- func (tc *TimeCache) Add(key string) error
- func (tc *TimeCache) AddWithSpan(key string, duration time.Duration) error
- func (tc *TimeCache) Has(key string) bool
- func (tc *TimeCache) IsInterfaceNil() bool
- func (tc *TimeCache) Len() int
- func (tc *TimeCache) Sweep()
- func (tc *TimeCache) Upsert(key string, duration time.Duration) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewPeerTimeCache ¶
func NewPeerTimeCache(timeCache types.TimeCacher) (*peerTimeCache, error)
NewPeerTimeCache creates a new peer time cache data structure instance
func NewTimeCacher ¶
func NewTimeCacher(arg ArgTimeCacher) (*timeCacher, error)
NewTimeCacher creates a new timeCacher
Types ¶
type ArgTimeCacher ¶
ArgTimeCacher is the argument used to create a new timeCacher instance
type TimeCache ¶
type TimeCache struct {
// contains filtered or unexported fields
}
TimeCache can retain an amount of string keys for a defined period of time sweeping (clean-up) is triggered each time a new item is added or a key is present in the time cache This data structure is concurrent safe.
func NewTimeCache ¶
NewTimeCache creates a new time cache data structure instance
func (*TimeCache) Add ¶
Add will store the key in the time cache Double adding the key is permitted. It will replace the data, if existing. It does not trigger sweep.
func (*TimeCache) AddWithSpan ¶
AddWithSpan will store the key in the time cache with the provided span duration Double adding the key is permitted. It will replace the data, if existing. It does not trigger sweep.
func (*TimeCache) IsInterfaceNil ¶
IsInterfaceNil returns true if there is no value under the interface
func (*TimeCache) Sweep ¶
func (tc *TimeCache) Sweep()
Sweep starts from the oldest element and will search each element if it is still valid to be kept. Sweep ends when it finds an element that is still valid