Documentation
¶
Index ¶
Constants ¶
const BucketNumber = 1 << 8
BucketNumber is the number of cache buckets
Variables ¶
This section is empty.
Functions ¶
func EstimateRate ¶
Types ¶
type BloomFilter ¶
BloomFilter holds all the storage filters.
func NewBloomFilter ¶
func NewBloomFilter(st StorageType, client *redis.Client, key string, n uint, p float64, cacheSize uint) (*BloomFilter, error)
NewBloomFilter creates and returns a new bloom filter using Redis as a backend. if you do not want to use cache, please set cacheSize to 0.
func (*BloomFilter) Append ¶
func (b *BloomFilter) Append(value []byte) (err error)
Append is used to append a value to the queue.
func (*BloomFilter) Exists ¶
func (b *BloomFilter) Exists(value []byte) (exists bool, err error)
Exists checks if the given value is in the bloom filter or not. False positives might occur.
func (*BloomFilter) ExistsAndAppend ¶
func (b *BloomFilter) ExistsAndAppend(value []byte) (exists bool, err error)
ExistsAndAppend check and append
type RedisStorage ¶
type RedisStorage struct {
// contains filtered or unexported fields
}
RedisStorage is a struct representing the Redis backend for the bloom filter.
func NewRedisStorage ¶
func NewRedisStorage(client *redis.Client, bf *BloomFilter, key string, hashIter uint, size uint) (*RedisStorage, error)
NewRedisStorage creates a Redis backend storage to be used with the bloom filter.
func (*RedisStorage) Append ¶
func (s *RedisStorage) Append(value []byte) error
Append appends the bit, which is to be saved, to the Redis.
func (*RedisStorage) Exists ¶
func (s *RedisStorage) Exists(value []byte) (ret bool, err error)
Exists checks if the given bit exists in the Redis backend.
func (*RedisStorage) ExistsAndAppend ¶
func (s *RedisStorage) ExistsAndAppend(value []byte) (ret bool, err error)
ExistsAndAppend checks and append
func (*RedisStorage) Init ¶
func (s *RedisStorage) Init(hashIter, size uint) (err error)
Init takes care of settings every bit to 0 in the Redis bitset.
type StorageType ¶
type StorageType int
StorageType is storage types
const ( // Redis type Redis StorageType = iota )
type UnavailableBloomType ¶
type UnavailableBloomType string
UnavailableBloomType bloom error
func (UnavailableBloomType) Error ¶
func (e UnavailableBloomType) Error() string