bloom

package
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BKDRHash

func BKDRHash(str string) uint64

BKDRHash 使用 BKDR 哈希算法计算字符串的哈希值 参数:

  • str: 输入字符串

返回:

  • uint64: 计算得到的哈希值

func DJBHash

func DJBHash(str string) uint64

DJBHash 使用 DJB 哈希算法计算字符串的哈希值 参数:

  • str: 输入字符串

返回:

  • uint64: 计算得到的哈希值

func SDBMHash

func SDBMHash(str string) uint64

SDBMHash 使用 SDBM 哈希算法计算字符串的哈希值 参数:

  • str: 输入字符串

返回:

  • uint64: 计算得到的哈希值

func WithExpire

func WithExpire(d time.Duration) func(*Options)

WithExpire 设置 Bloom 过滤器的过期时间

func WithHash

func WithHash(f ...func(str string) uint64) func(*Options)

WithHash 添加自定义的哈希函数

func WithKey

func WithKey(key string) func(*Options)

WithKey 设置 Bloom 过滤器在 Redis 中使用的键名

func WithRedis

func WithRedis(rd redis.UniversalClient) func(*Options)

WithRedis 设置 Redis 客户端

func WithTimeout

func WithTimeout(d time.Duration) func(*Options)

WithTimeout 设置操作超时时间

Types

type Bloom

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

Bloom 结构体定义布隆过滤器

func New

func New(options ...func(*Options)) (*Bloom, error)

New 创建一个新的布隆过滤器实例

func (*Bloom) Add

func (b *Bloom) Add(ctx context.Context, str ...string) error

Add 将一个或多个字符串添加到布隆过滤器中

func (*Bloom) Exist

func (b *Bloom) Exist(ctx context.Context, str string) (bool, error)

Exist 检查字符串是否可能存在于布隆过滤器中

func (*Bloom) Flush

func (b *Bloom) Flush(ctx context.Context) error

Flush 清空布隆过滤器

type Options

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

Options 定义了 Bloom 过滤器的配置选项

func DefaultOptions

func DefaultOptions() *Options

DefaultOptions 返回默认的 Options 配置

func (*Options) Validate

func (o *Options) Validate() error

Validate 验证 Options 的配置是否有效

Jump to

Keyboard shortcuts

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