Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FirstSeenCache ¶
type FirstSeenCache struct {
// contains filtered or unexported fields
}
FirstSeenCache is a thread-safe copy of https://github.com/whyrusleeping/timecache.
func (FirstSeenCache) Add ¶
func (tc FirstSeenCache) Add(s string)
func (FirstSeenCache) Has ¶
func (tc FirstSeenCache) Has(s string) bool
type LastSeenCache ¶
type LastSeenCache struct {
// contains filtered or unexported fields
}
LastSeenCache is a LRU cache that keeps entries for up to a specified time duration. After this duration has elapsed, "old" entries will be purged from the cache.
It's also a "sliding window" cache. Every time an unexpired entry is seen again, its timestamp slides forward. This keeps frequently occurring entries cached and prevents them from being propagated, especially because of network issues that might increase the number of duplicate messages in the network.
Garbage collection of expired entries is event-driven, i.e. it only happens when there is a new entry added to the cache. This should be ok - if existing entries are being looked up then the cache is not growing, and when a new one appears that would grow the cache, garbage collection will attempt to reduce the pressure on the cache.
This implementation is heavily inspired by https://github.com/whyrusleeping/timecache.
func (*LastSeenCache) Add ¶
func (tc *LastSeenCache) Add(s string)
func (*LastSeenCache) Has ¶
func (tc *LastSeenCache) Has(s string) bool
type TimeCache ¶
func NewTimeCache ¶
NewTimeCache defaults to the original ("first seen") cache implementation