Documentation ¶
Index ¶
- type Cache
- type ChanMessage
- type Entry
- type LRUCache
- func (l *LRUCache) Contains(key any) bool
- func (l *LRUCache) Get(key any) (any, bool)
- func (l *LRUCache) HitRate() (int, int)
- func (l *LRUCache) Iterator(do func(k, v any) error)
- func (l *LRUCache) Length() int
- func (l *LRUCache) Put(key, v any, ttl time.Duration) chan time.Time
- func (l *LRUCache) Remove(key any) any
- type Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache struct { sync.RWMutex // MaxEntries is the maximum number of c entries before // an item is evicted. Zero means no limit. MaxEntries int // OnEvicted optionally a callback function to be // executed when an entry is purged from the c. OnEvicted func(key, value any) // contains filtered or unexported fields }
c is an LRU c. It is not safe for concurrent access.
func New ¶
New creates a new c. If maxEntries is zero, the c has no limit and it's assumed that eviction is done by the caller.
type ChanMessage ¶
type ChanMessage struct {
Key any `json:"k"`
}
type LRUCache ¶
type LRUCache struct {
// contains filtered or unexported fields
}
func NewLRUCache ¶
Click to show internal directories.
Click to hide internal directories.