Skip to content

Commit 9d403c4

Browse files
authored
Adding a quick start guide for bloom (#54)
Signed-off-by: zackcam <[email protected]>
1 parent 60513c7 commit 9d403c4

File tree

2 files changed

+58
-2
lines changed

2 files changed

+58
-2
lines changed

QUICK_START.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Quick Start
2+
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+
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:
14+
15+
In case of Linux:
16+
```bash
17+
./valkey-server --loadmodule ./target/release/libvalkey_bloom.so
18+
```
19+
20+
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 then there is a possibility (determined by false positive rate) that the item is not actually present.

build.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,6 @@ if [[ "$os_type" == "Darwin" ]]; then
7878
MODULE_EXT=".dylib"
7979
elif [[ "$os_type" == "Linux" ]]; then
8080
MODULE_EXT=".so"
81-
elif [[ "$os_type" == "Windows" ]]; then
82-
MODULE_EXT=".dll"
8381
else
8482
echo "Unsupported OS type: $os_type"
8583
exit 1

0 commit comments

Comments
 (0)