You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
+
5
+
## Step 1: Install Valkey and valkey-bloom
6
+
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
+
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
+
11
+
## Step 2: Run the Valkey Server with valkey-bloom
12
+
13
+
Once valkey-bloom is built, run the Valkey server with the module loaded:
You should see the Valkey server start, and it will be ready to accept commands.
21
+
22
+
## Step 3: Create a Bloom Filter
23
+
24
+
Start a Valkey CLI session:
25
+
26
+
```bash
27
+
valkey-cli
28
+
```
29
+
30
+
Create a bloom filter using the BF.ADD, BF.INSERT, BF.RESERVE or BF.MADD commands. For example:
31
+
32
+
```bash
33
+
BF.ADD filter-key item-val
34
+
```
35
+
36
+
-`filter-key` is the name of the bloom filter we will be operating on
37
+
-`item-val` is the item we are inserting into the bloom filter
38
+
39
+
## Step 4: Insert some more items
40
+
41
+
To insert items on an already created filter, use the `BF.ADD`, `BF.MADD` or `BF.INSERT` commands:
42
+
43
+
```bash
44
+
BF.ADD filter-key example
45
+
BF.MADD filter-key example1 example2
46
+
```
47
+
48
+
Replace the example with the actual items you want to add.
49
+
50
+
## Step 5: Check if items are present
51
+
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
+
54
+
```bash
55
+
BF.EXISTS filter-key example
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, there is a possibility (determined by false positive rate) that the item is not actually present.
Copy file name to clipboardExpand all lines: README.md
+6-3
Original file line number
Diff line number
Diff line change
@@ -1,10 +1,10 @@
1
1
# valkey-bloom
2
2
3
-
Valkey-Bloom (BSD-3-Clause) is a Rust Valkey-Module which brings a native and space efficient probabilistic Module data type to Valkey. With this, users can create filters (space-efficient probabilistic Module data type) to add elements, perform “check” operation to test whether an element exists, auto scale their filters, perform RDB Save and load operations, etc.
3
+
Valkey-Bloom (BSD-3-Clause) is a Rust based Valkey-Module which brings a Bloom Filter (Module) data type into Valkey and supports verions >= 8.0. With this, users can create bloom filters (spaceefficient probabilistic data structures) to add elements, checkwhether elements exists, auto scale their filters, customize bloom filter properties, perform RDB Save and load operations, etc.
4
4
5
5
Valkey-Bloom is built using `bloomfilter::Bloom` (https://crates.io/crates/bloomfilter which has a BSD-2-Clause license).
6
6
7
-
It is compatible with the BloomFilter (BF.*) command APIs in Redis offerings.
7
+
It is API compatible with the bloom filter command syntax of the official Valkey client libraries including valkey-py, valkey-java, valkey-go (as well as the equivalent Redis libraries)
8
8
9
9
## Supported commands
10
10
```
@@ -25,7 +25,10 @@ curl https://sh.rustup.rs -sSf | sh
0 commit comments