internal

package
v0.4.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 13, 2023 License: MIT Imports: 2 Imported by: 0

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.

func (*BloomFilter) Reset

func (f *BloomFilter) Reset()

Reset clears the bloom 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.

func (*CountMinSketch) Reset

func (c *CountMinSketch) Reset()

Reset divides all counters by two.

type Hash

type Hash interface {
	Sum64() uint64
}

Hash is an interface implemented by cache keys to override default hash function.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL