pub trait BloomCommands<'a> {
// Provided methods
fn bf_add(
self,
key: impl SingleArg,
item: impl SingleArg,
) -> PreparedCommand<'a, Self, bool>
where Self: Sized { ... }
fn bf_exists(
self,
key: impl SingleArg,
item: impl SingleArg,
) -> PreparedCommand<'a, Self, bool>
where Self: Sized { ... }
fn bf_info_all(
self,
key: impl SingleArg,
) -> PreparedCommand<'a, Self, BfInfoResult>
where Self: Sized { ... }
fn bf_info(
self,
key: impl SingleArg,
param: BfInfoParameter,
) -> PreparedCommand<'a, Self, usize>
where Self: Sized { ... }
fn bf_insert<I: SingleArg, R: CollectionResponse<bool>>(
self,
key: impl SingleArg,
items: impl SingleArgCollection<I>,
options: BfInsertOptions,
) -> PreparedCommand<'a, Self, R>
where Self: Sized { ... }
fn bf_loadchunk(
self,
key: impl SingleArg,
iterator: i64,
data: impl SingleArg,
) -> PreparedCommand<'a, Self, ()>
where Self: Sized { ... }
fn bf_madd<I: SingleArg, R: CollectionResponse<bool>>(
self,
key: impl SingleArg,
items: impl SingleArgCollection<I>,
) -> PreparedCommand<'a, Self, R>
where Self: Sized { ... }
fn bf_mexists<I: SingleArg, R: CollectionResponse<bool>>(
self,
key: impl SingleArg,
items: impl SingleArgCollection<I>,
) -> PreparedCommand<'a, Self, R>
where Self: Sized { ... }
fn bf_reserve(
self,
key: impl SingleArg,
error_rate: f64,
capacity: usize,
options: BfReserveOptions,
) -> PreparedCommand<'a, Self, ()>
where Self: Sized { ... }
fn bf_scandump(
self,
key: impl SingleArg,
iterator: i64,
) -> PreparedCommand<'a, Self, BfScanDumpResult>
where Self: Sized { ... }
}
redis-bloom
only.Expand description
Provided Methods§
Sourcefn bf_add(
self,
key: impl SingleArg,
item: impl SingleArg,
) -> PreparedCommand<'a, Self, bool>where
Self: Sized,
fn bf_add(
self,
key: impl SingleArg,
item: impl SingleArg,
) -> PreparedCommand<'a, Self, bool>where
Self: Sized,
Sourcefn bf_exists(
self,
key: impl SingleArg,
item: impl SingleArg,
) -> PreparedCommand<'a, Self, bool>where
Self: Sized,
fn bf_exists(
self,
key: impl SingleArg,
item: impl SingleArg,
) -> PreparedCommand<'a, Self, bool>where
Self: Sized,
Sourcefn bf_info_all(
self,
key: impl SingleArg,
) -> PreparedCommand<'a, Self, BfInfoResult>where
Self: Sized,
fn bf_info_all(
self,
key: impl SingleArg,
) -> PreparedCommand<'a, Self, BfInfoResult>where
Self: Sized,
Return information about key filter.
§Arguments
key
- Name of the key to return information about
§Return
an instance of BfInfoResult
§See Also
Sourcefn bf_info(
self,
key: impl SingleArg,
param: BfInfoParameter,
) -> PreparedCommand<'a, Self, usize>where
Self: Sized,
fn bf_info(
self,
key: impl SingleArg,
param: BfInfoParameter,
) -> PreparedCommand<'a, Self, usize>where
Self: Sized,
Sourcefn bf_insert<I: SingleArg, R: CollectionResponse<bool>>(
self,
key: impl SingleArg,
items: impl SingleArgCollection<I>,
options: BfInsertOptions,
) -> PreparedCommand<'a, Self, R>where
Self: Sized,
fn bf_insert<I: SingleArg, R: CollectionResponse<bool>>(
self,
key: impl SingleArg,
items: impl SingleArgCollection<I>,
options: BfInsertOptions,
) -> PreparedCommand<'a, Self, R>where
Self: Sized,
bf_insert
is a sugarcoated combination of bf_reserve
and bf_add
.
It creates a new filter if the key does not exist using the relevant arguments (see bf_reserve
).
Next, all ITEMS are inserted.
§Arguments
key
- The name of the filteritems
- One or more items to addoptions
- SeeBfInsertOptions
§Return
A collection of booleans (integers).
Each element is either true or false depending on whether the corresponding input element was newly added to the filter or may have previously existed.
§See Also
Sourcefn bf_loadchunk(
self,
key: impl SingleArg,
iterator: i64,
data: impl SingleArg,
) -> PreparedCommand<'a, Self, ()>where
Self: Sized,
fn bf_loadchunk(
self,
key: impl SingleArg,
iterator: i64,
data: impl SingleArg,
) -> PreparedCommand<'a, Self, ()>where
Self: Sized,
Restores a filter previously saved using bf_scandump
.
See the bf_scandump
command for example usage.
This command overwrites any bloom filter stored under key. Make sure that the bloom filter is not be changed between invocations.
§Arguments
key
- Name of the key to restoreiterator
- Iterator value associated withdata
(returned bybf_scandump
)data
- Current data chunk (returned bybf_scandump
)
§See Also
Sourcefn bf_madd<I: SingleArg, R: CollectionResponse<bool>>(
self,
key: impl SingleArg,
items: impl SingleArgCollection<I>,
) -> PreparedCommand<'a, Self, R>where
Self: Sized,
fn bf_madd<I: SingleArg, R: CollectionResponse<bool>>(
self,
key: impl SingleArg,
items: impl SingleArgCollection<I>,
) -> PreparedCommand<'a, Self, R>where
Self: Sized,
Adds one or more items to the Bloom Filter and creates the filter if it does not exist yet.
This command operates identically to bf_add
except that it allows multiple inputs and returns multiple values.
§Arguments
key
- The name of the filteritems
- One or more items to add
§Return
Collection reply of boolean - for each item which is either true
or false
depending
on whether the corresponding input element was newly added to the filter or may have previously existed.
§See Also
Sourcefn bf_mexists<I: SingleArg, R: CollectionResponse<bool>>(
self,
key: impl SingleArg,
items: impl SingleArgCollection<I>,
) -> PreparedCommand<'a, Self, R>where
Self: Sized,
fn bf_mexists<I: SingleArg, R: CollectionResponse<bool>>(
self,
key: impl SingleArg,
items: impl SingleArgCollection<I>,
) -> PreparedCommand<'a, Self, R>where
Self: Sized,
Determines if one or more items may exist in the filter or not.
§Arguments
key
- The name of the filteritems
- One or more items to check
§Return
Collection reply of boolean - for each item where true
value means the corresponding item
may exist in the filter, and a false
value means it does not exist in the filter.
§See Also
Sourcefn bf_reserve(
self,
key: impl SingleArg,
error_rate: f64,
capacity: usize,
options: BfReserveOptions,
) -> PreparedCommand<'a, Self, ()>where
Self: Sized,
fn bf_reserve(
self,
key: impl SingleArg,
error_rate: f64,
capacity: usize,
options: BfReserveOptions,
) -> PreparedCommand<'a, Self, ()>where
Self: Sized,
Creates an empty Bloom Filter with a single sub-filter for the initial capacity requested and with an upper bound error_rate.
By default, the filter auto-scales by creating additional sub-filters when capacity is reached. The new sub-filter is created with size of the previous sub-filter multiplied by expansion.
Though the filter can scale up by creating sub-filters, it is recommended to reserve the estimated required capacity since maintaining and querying sub-filters requires additional memory (each sub-filter uses an extra bits and hash function) and consume further CPU time than an equivalent filter that had the right capacity at creation time.
The number of hash functions is log(error)/ln(2)^2
. The number of bits per item is log(error)/ln(2)
≈ 1.44.
- 1% error rate requires 7 hash functions and 10.08 bits per item.
- 0.1% error rate requires 10 hash functions and 14.4 bits per item.
- 0.01% error rate requires 14 hash functions and 20.16 bits per item.
§Arguments
key
- The key under which the filter is founderror_rate
- The desired probability for false positives. The rate is a decimal value between 0 and 1. For example, for a desired false positive rate of 0.1% (1 in 1000), error_rate should be set to 0.001.capacity
- The number of entries intended to be added to the filter. If your filter allows scaling, performance will begin to degrade after adding more items than this number. The actual degradation depends on how far the limit has been exceeded. Performance degrades linearly with the number ofsub-filters
.options
- SeeBfReserveOptions
§See Also
Sourcefn bf_scandump(
self,
key: impl SingleArg,
iterator: i64,
) -> PreparedCommand<'a, Self, BfScanDumpResult>where
Self: Sized,
fn bf_scandump(
self,
key: impl SingleArg,
iterator: i64,
) -> PreparedCommand<'a, Self, BfScanDumpResult>where
Self: Sized,
Begins an incremental save of the bloom filter.
This is useful for large bloom filters which cannot fit into the normal dump
and restore
model.
§Arguments
key
- Name of the filteriterator
- Iterator value; either 0 or the iterator from a previous invocation of this command.
The first time this command is called, the value ofiterator
should be 0.
§Return
This command returns successive (iterator, data)
pairs until (0, vec![])
to indicate completion.