Documentation
¶
Overview ¶
Package internal contains data structures used by cache implementations.
These data structures are derived from the Mango Cache source code. See NOTICE for important copyright and licensing information.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ComputeHash ¶
func ComputeHash(k interface{}) uint64
ComputeHash calculates hash value of the given key.
Types ¶
type BloomFilter ¶
type BloomFilter struct {
// contains filtered or unexported fields
}
BloomFilter is Bloom Filter implementation used as a cache admission policy. See http://billmill.org/bloomfilter-tutorial/
func (*BloomFilter) Contains ¶
func (f *BloomFilter) Contains(h uint64) bool
contains returns true if the given hash is may be in the filter.
func (*BloomFilter) Init ¶
func (f *BloomFilter) Init(ins int, fpp float64)
Init initializes bloomFilter with the given expected insertions ins and false positive probability fpp.
func (*BloomFilter) Put ¶
func (f *BloomFilter) Put(h uint64) bool
Put inserts a hash value into the bloom filter. It returns true if the value may already in the filter.
type CountMinSketch ¶
type CountMinSketch struct {
// contains filtered or unexported fields
}
CountMinSketch is an implementation of count-min sketch with 4-bit counters. See http://dimacs.rutgers.edu/~graham/pubs/papers/cmsoft.pdf
func (*CountMinSketch) Add ¶
func (c *CountMinSketch) Add(h uint64)
Add increases counters associated with the given hash.
func (*CountMinSketch) Estimate ¶
func (c *CountMinSketch) Estimate(h uint64) uint8
Estimate returns minimum value of counters associated with the given hash.
func (*CountMinSketch) Init ¶
func (c *CountMinSketch) Init(width int)
init initialize count-min sketch with the given width.