Documentation
¶
Overview ¶
Package cuckoo provides a Cuckoo filter implementation for probabilistic existence checks. Unlike Bloom filters, Cuckoo filters support deletion of individual items.
Example:
storage := memory.New(memory.WithCapacity(100000)) filter := cuckoo.New(storage) filter.Add(ctx, "user:123") exists, _ := filter.MightExist(ctx, "user:123") // true filter.Delete(ctx, "user:123") exists, _ = filter.MightExist(ctx, "user:123") // false
Index ¶
- type Filter
- func (f *Filter) Add(ctx context.Context, value string) error
- func (f *Filter) AddBatch(ctx context.Context, values iter.Seq[string]) error
- func (f *Filter) Close(ctx context.Context) error
- func (f *Filter) Delete(ctx context.Context, value string) (bool, error)
- func (f *Filter) MightExist(ctx context.Context, value string) (bool, error)
- func (f *Filter) Stats(ctx context.Context) (*probfilter.FilterStats, error)
- type Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Filter ¶
type Filter struct {
// contains filtered or unexported fields
}
Filter is a Cuckoo filter facade that wraps a storage backend. It implements probfilter.DeletableFilter.
func New ¶
New creates a new Cuckoo filter with the specified storage backend.
Example:
storage := memory.New(memory.WithCapacity(100000)) filter := cuckoo.New(storage)
func (*Filter) MightExist ¶
MightExist checks if a value might exist in the filter.
func (*Filter) Stats ¶
func (f *Filter) Stats(ctx context.Context) (*probfilter.FilterStats, error)
Stats returns current filter statistics.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package storages defines the storage interface for Cuckoo filter backends.
|
Package storages defines the storage interface for Cuckoo filter backends. |
|
memory
Package memory provides an in-memory Cuckoo filter storage implementation using the seiflotfy/cuckoofilter library.
|
Package memory provides an in-memory Cuckoo filter storage implementation using the seiflotfy/cuckoofilter library. |
|
redis
Package redis provides a Redis-backed Cuckoo filter storage implementation using RedisBloom module CF.* commands.
|
Package redis provides a Redis-backed Cuckoo filter storage implementation using RedisBloom module CF.* commands. |
Click to show internal directories.
Click to hide internal directories.