Documentation
¶
Overview ¶
Package cache provides basic block cache types for the bgzf package.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Cache ¶
type Cache interface {
bgzf.Cache
// Len returns the number of elements held by
// the cache.
Len() int
// Cap returns the maximum number of elements
// that can be held by the cache.
Cap() int
// Resize changes the capacity of the cache to n,
// dropping excess blocks if n is less than the
// number of cached blocks.
Resize(n int)
// Drop evicts n elements from the cache according
// to the cache eviction policy.
Drop(n int)
}
Cache is an extension of bgzf.Cache that allows inspection and manipulation of the cache.
func NewFIFO ¶
NewFIFO returns a FIFO cache with n slots. If n is less than 1 a nil cache is returned.
type FIFO ¶
type FIFO struct {
// contains filtered or unexported fields
}
FIFO satisfies the Cache interface with first in first out eviction behavior where Unused Blocks are preferentially evicted.
func (*FIFO) Get ¶
Get returns the Block in the Cache with the specified base or a nil Block if it does not exist.
func (*FIFO) Peek ¶
Peek returns a boolean indicating whether a Block exists in the Cache for the given base offset and the expected offset for the subsequent Block in the BGZF stream.
type LRU ¶
type LRU struct {
// contains filtered or unexported fields
}
LRU satisfies the Cache interface with least recently used eviction behavior where Unused Blocks are preferentially evicted.
func (*LRU) Get ¶
Get returns the Block in the Cache with the specified base or a nil Block if it does not exist.
func (*LRU) Peek ¶
Peek returns a boolean indicating whether a Block exists in the Cache for the given base offset and the expected offset for the subsequent Block in the BGZF stream.
type Random ¶
type Random struct {
// contains filtered or unexported fields
}
Random satisfies the Cache interface with random eviction behavior where Unused Blocks are preferentially evicted.
func (*Random) Get ¶
Get returns the Block in the Cache with the specified base or a nil Block if it does not exist.
func (*Random) Peek ¶
Peek returns a boolean indicating whether a Block exists in the Cache for the given base offset and the expected offset for the subsequent Block in the BGZF stream.
type Stats ¶
type Stats struct {
Gets int // number of Get operations
Misses int // number of cache misses
Puts int // number of Put operations
Retains int // number of times a Put has resulted in Block retention
Evictions int // number of times a Put has resulted in a Block eviction
}
Stats represents statistics of a bgzf.Cache.
type StatsRecorder ¶
StatsRecorder allows a bgzf.Cache to capture cache statistics.
func (*StatsRecorder) Get ¶
func (s *StatsRecorder) Get(base int64) bgzf.Block
Get returns the Block in the underlying Cache with the specified base or a nil Block if it does not exist. It updates the gets and misses statistics.
func (*StatsRecorder) Put ¶
Put inserts a Block into the underlying Cache, returning the Block and eviction status according to the underlying cache behavior. It updates the puts, retains and evictions statistics.
func (*StatsRecorder) Reset ¶
func (s *StatsRecorder) Reset()
Reset zeros the statistics kept by the StatsRecorder.
func (*StatsRecorder) Stats ¶
func (s *StatsRecorder) Stats() Stats
Stats returns the current statistics for the cache.