|
1 | 1 | # Quick Start
|
2 |
| - |
| 2 | + |
3 | 3 | Follow these steps to set up, build, and run the Valkey server with the valkey-bloom module. This guide will walk you through creating a bloom filter, inserting items, and checking for items in the filters.
|
4 |
| - |
| 4 | + |
5 | 5 | ## Step 1: Install Valkey and valkey-bloom
|
6 |
| - |
| 6 | + |
7 | 7 | 1. Build Valkey from source by following the instructions [here](https://github.com/valkey-io/valkey?tab=readme-ov-file#building-valkey-using-makefile). Make sure to use Valkey version 8.0 or above.
|
8 |
| - |
| 8 | + |
9 | 9 | 2. Build the valkey-bloom module from source by following the instructions [here](https://github.com/valkey-io/valkey-bloom/blob/unstable/README.md#build-instructions).
|
10 |
| - |
| 10 | + |
11 | 11 | ## Step 2: Run the Valkey Server with valkey-bloom
|
12 |
| - |
| 12 | + |
13 | 13 | Once valkey-bloom is built, run the Valkey server with the module loaded:
|
14 |
| - |
| 14 | + |
15 | 15 | In case of Linux:
|
16 | 16 | ```bash
|
17 | 17 | ./valkey-server --loadmodule ./target/release/libvalkey_bloom.so
|
18 | 18 | ```
|
19 |
| - |
| 19 | + |
20 | 20 | You should see the Valkey server start, and it will be ready to accept commands.
|
21 |
| - |
| 21 | + |
22 | 22 | ## Step 3: Create a Bloom Filter
|
23 |
| - |
| 23 | + |
24 | 24 | Start a Valkey CLI session:
|
25 |
| - |
| 25 | + |
26 | 26 | ```bash
|
27 | 27 | valkey-cli
|
28 | 28 | ```
|
29 |
| - |
| 29 | + |
30 | 30 | Create a bloom filter using the BF.ADD, BF.INSERT, BF.RESERVE or BF.MADD commands. For example:
|
31 |
| - |
| 31 | + |
32 | 32 | ```bash
|
33 | 33 | BF.ADD filter-key item-val
|
34 | 34 | ```
|
35 |
| - |
| 35 | + |
36 | 36 | - `filter-key` is the name of the bloom filter we will be operating on
|
37 | 37 | - `item-val` is the item we are inserting into the bloom filter
|
38 |
| - |
| 38 | + |
39 | 39 | ## Step 4: Insert some more items
|
40 |
| - |
| 40 | + |
41 | 41 | To insert items on an already created filter, use the `BF.ADD`, `BF.MADD` or `BF.INSERT` commands:
|
42 |
| - |
| 42 | + |
43 | 43 | ```bash
|
44 | 44 | BF.ADD filter-key example
|
45 | 45 | BF.MADD filter-key example1 example2
|
46 | 46 | ```
|
47 |
| - |
| 47 | + |
48 | 48 | Replace the example with the actual items you want to add.
|
49 |
| - |
| 49 | + |
50 | 50 | ## Step 5: Check if items are present
|
51 |
| - |
| 51 | + |
52 | 52 | Now that you've created a bloom filter and inserted items, you can check what items have been added. Use the `BF.EXISTS` or `BF.MEXISTS` commands to check for items:
|
53 |
| - |
| 53 | + |
54 | 54 | ```bash
|
55 | 55 | BF.EXISTS filter-key example
|
56 | 56 | ```
|
57 |
| - |
58 |
| -This command checks if an item is present in a bloom filter. Bloom filters can have false positives, but no false negatives. This means that if the BF.EXISTS command returns 0, then the item is not present. But if the BF.EXISTS command returns 1 then there is a possibility (determined by false positive rate) that the item is not actually present. |
| 57 | + |
| 58 | +This command checks if an item is present in a bloom filter. Bloom filters can have false positives, but no false negatives. This means that if the BF.EXISTS command returns 0, then the item is not present. But if the BF.EXISTS command returns 1, there is a possibility (determined by false positive rate) that the item is not actually present. |
0 commit comments