cache

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2025 License: BSD-3-Clause Imports: 6 Imported by: 1 module, 3 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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