cache

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2026 License: BSD-3-Clause Imports: 6 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BloomFilter added in v0.2.0

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

BloomFilter represents a bloom filter with a fixed number of bits and hash functions.

func NewBloomFilter

func NewBloomFilter(expectedItems uint64, falsePositiveRate float64) (r *BloomFilter)

NewBloomFilter creates a new bloom filter with the specified size, hash function count, and capacity.

func (*BloomFilter) Add added in v0.2.0

func (bf *BloomFilter) Add(item []byte)

Add adds an item (as byte slice) to the bloom filter using multiple hash functions.

func (*BloomFilter) Contains added in v0.2.0

func (bf *BloomFilter) Contains(item []byte) bool

Contains if an item (as byte slice) is possibly in the bloom filter.

func (*BloomFilter) String added in v0.2.0

func (bf *BloomFilter) String() string

type LruCache

type LruCache[T any] struct {
	// contains filtered or unexported fields
}

func NewLruCache

func NewLruCache[T any](maxEntries int) *LruCache[T]

func (*LruCache[T]) Add

func (lc *LruCache[T]) Add(key lru.Key, value T)

Add adds a value to the cache. It uses Lock for exclusive writes.

func (*LruCache[T]) Get

func (lc *LruCache[T]) Get(key lru.Key) (value T, b bool)

Get retrieves a value from the cache. It uses RLock for concurrent reads.

func (*LruCache[T]) Remove

func (lc *LruCache[T]) Remove(key lru.Key)

Remove deletes an entry from the cache. It uses Lock for exclusive writes.

func (*LruCache[T]) RemoveMulti

func (lc *LruCache[T]) RemoveMulti(keys []string)

RemoveMulti deletes multiple entries from the cache. It uses Lock for exclusive writes.

Jump to

Keyboard shortcuts

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