Documentation
¶
Overview ¶
Package lrucache is the bounded, sharded LRU of the answers of one segment of the resolver, with a time to live for members and one for non members, and a version token that turns the entries of an older version into misses.
Index ¶
- type Cache
- func (c *Cache) Clear()
- func (c *Cache) Current() string
- func (c *Cache) Generation() uint64
- func (c *Cache) Get(key string, now time.Time) (segment.State, bool)
- func (c *Cache) Len() int
- func (c *Cache) Put(key string, state segment.State, now time.Time)
- func (c *Cache) SetVersion(token string) bool
- type Config
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache is a bounded LRU of the answers of one segment, with a TTL for members and one for non members.
func (*Cache) Current ¶
Current returns the version token, empty when none was learned. It does not allocate.
func (*Cache) Generation ¶
Generation is the generation of the version token: it grows on every change of the token.
func (*Cache) SetVersion ¶
SetVersion starts a new generation when the token differs from the current one: the entries of every earlier generation become misses, without being touched, and age out of the LRU. A token that comes back is a new generation too, so its old entries never revive. It reports whether the token changed.
type Config ¶
type Config struct {
// MaxEntries bounds the entries of the whole cache.
MaxEntries int
// Shards is the number of locks.
Shards int
// TTL is how long a Member is kept.
TTL time.Duration
// NegativeTTL is how long a NotMember is kept.
NegativeTTL time.Duration
}
Config is the size and the lifetimes of a cache.