cache

package
v0.0.0-...-8eacd36 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	STAGE_ONE = iota + 1
	STAGE_TWO
)

Variables

This section is empty.

Functions

func Hash

func Hash(b []byte) uint32

Hash implements a hashing algorithm similar to the Murmur hash.

func MemHash

func MemHash(data []byte) uint64

func MemHashString

func MemHashString(str string) uint64

MemHashString is the hash function used by go map, it utilizes available hardware instructions (behaves as aeshash if aes instruction is available). NOTE: The hash seed changes for every process. So, this cannot be used as a persistent hash.

Types

type BloomFilter

type BloomFilter struct {
	// contains filtered or unexported fields
}

func (*BloomFilter) Allow

func (f *BloomFilter) Allow(h uint32) bool

func (*BloomFilter) AllowKey

func (f *BloomFilter) AllowKey(k []byte) bool

func (*BloomFilter) Insert

func (f *BloomFilter) Insert(h uint32) bool

func (*BloomFilter) InsertKey

func (f *BloomFilter) InsertKey(k []byte) bool

func (*BloomFilter) Len

func (f *BloomFilter) Len() int32

func (*BloomFilter) MayContain

func (f *BloomFilter) MayContain(h uint32) bool

MayContain returns whether the filter may contain given key. False positives are possible, where it returns true for keys not in the original set.

func (*BloomFilter) MayContainKey

func (f *BloomFilter) MayContainKey(k []byte) bool

MayContainKey _

type Cache

type Cache struct {
	// contains filtered or unexported fields
}

func NewCache

func NewCache(size int) *Cache

NewCache size 指的是要缓存的数据个数

func (*Cache) Del

func (c *Cache) Del(key interface{}) (interface{}, bool)

func (*Cache) Get

func (c *Cache) Get(key interface{}) (interface{}, bool)

func (*Cache) Set

func (c *Cache) Set(key interface{}, value interface{}) bool

func (*Cache) String

func (c *Cache) String() string

type Filter

type Filter []byte

Filter is an encoded set of []byte keys.

type Options

type Options struct {
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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