Trait rustis::commands::BloomCommands

source ·
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 { ... }
}
Available on crate feature redis-bloom only.
Expand description

A group of Redis commands related to Bloom filters

§See Also

Bloom Filter Commands

Provided Methods§

source

fn bf_add( self, key: impl SingleArg, item: impl SingleArg ) -> PreparedCommand<'a, Self, bool>
where Self: Sized,

Adds an item to a bloom filter

§Arguments
  • key - The name of the filter
  • item - The item to add
§Return
  • true - if the item did not exist in the filter,
  • false - otherwise.
§See Also
source

fn bf_exists( self, key: impl SingleArg, item: impl SingleArg ) -> PreparedCommand<'a, Self, bool>
where Self: Sized,

Determines whether an item may exist in the Bloom Filter or not.

§Arguments
  • key - The name of the filter
  • item - The item to check for
§Return
  • true - means the item may exist in the filter,
  • false - means it does not exist in the filter..
§See Also
source

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

https://redis.io/commands/bf.info/

source

fn bf_info( self, key: impl SingleArg, param: BfInfoParameter ) -> PreparedCommand<'a, Self, usize>
where Self: Sized,

Return information about key filter for a specific information parameter

§Arguments
  • key - Name of the key to return information about
  • param - specific information parameter to query
§Return

The value of the requested parameter

§See Also

https://redis.io/commands/bf.info/

source

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 filter
  • items - One or more items to add
  • options - See BfInsertOptions
§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

https://redis.io/commands/bf.insert/

source

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 restore
  • iterator - Iterator value associated with data (returned by bf_scandump)
  • data - Current data chunk (returned by bf_scandump)
§See Also

https://redis.io/commands/bf.loadchunk/

source

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 filter
  • items - 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

https://redis.io/commands/bf.madd/

source

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 filter
  • items - 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

https://redis.io/commands/bf.mexists/

source

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 found
  • error_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 of sub-filters.
  • options - See BfReserveOptions
§See Also

https://redis.io/commands/bf.reserve/

source

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 filter
  • iterator - Iterator value; either 0 or the iterator from a previous invocation of this command.
    The first time this command is called, the value of iterator should be 0.
§Return

This command returns successive (iterator, data) pairs until (0, vec![]) to indicate completion.

§See Also

https://redis.io/commands/bf.scandump/

Implementors§

source§

impl<'a> BloomCommands<'a> for &'a Client

source§

impl<'a> BloomCommands<'a> for &'a mut Transaction

source§

impl<'a, 'b> BloomCommands<'a> for &'a mut Pipeline<'b>