Documentation
¶
Index ¶
- type EvictCallback
- type EvictionReason
- type FIFO
- func (f *FIFO) Add(key uuid.UUID, value models.Record) bool
- func (f *FIFO) Contains(key uuid.UUID) bool
- func (f *FIFO) Dequeue(fn func(uuid.UUID, models.Record) error) ([]KeyValue, error)
- func (f *FIFO) Get(key uuid.UUID) (models.Record, bool)
- func (f *FIFO) Keys() []uuid.UUID
- func (f *FIFO) Len() int
- func (f *FIFO) Pop() (uuid.UUID, models.Record, bool)
- func (f *FIFO) Purge()
- func (f *FIFO) Remove(key uuid.UUID) bool
- func (f *FIFO) Slice() []KeyValue
- type KeyValue
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EvictCallback ¶
type EvictCallback func(EvictionReason, uuid.UUID, models.Record)
EvictCallback lets you know when an eviction has happened in the cache
type EvictionReason ¶
type EvictionReason int
EvictionReason describes why the eviction happened
const ( // Purged by calling reset Purged EvictionReason = iota // Popped manually from the cache Popped // Removed manually from the cache Removed // Dequeued by walking over due to being dequeued Dequeued )
type FIFO ¶
type FIFO struct {
// contains filtered or unexported fields
}
func NewFIFO ¶
func NewFIFO(onEvict EvictCallback) *FIFO
NewFIFO implements a non-thread safe FIFO cache
func (*FIFO) Add ¶
Add adds a key, value pair.
func (*FIFO) Contains ¶
Contains finds out if a key is present in the LRU cache
func (*FIFO) Dequeue ¶
Dequeue iterates over the LRU cache removing an item upon each iteration.
func (*FIFO) Get ¶
Get returns back a value if it exists. Returns true if found.
func (*FIFO) Pop ¶
Pop removes the last FIFO item with in the cache
func (*FIFO) Purge ¶
func (f *FIFO) Purge()
Purge removes all items with in the cache, calling evict callback on each.
func (*FIFO) Remove ¶
Remove a value using it's key Returns true if a removal happened
Source Files
¶
- fifo.go
Click to show internal directories.
Click to hide internal directories.