Skip to content

Commit 1bb7d25

Browse files
Update README.md (#39)
Signed-off-by: KarthikSubbarao <[email protected]>
1 parent a9b578e commit 1bb7d25

File tree

2 files changed

+23
-79
lines changed

2 files changed

+23
-79
lines changed

README.md

Lines changed: 22 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ Valkey-Bloom (BSD-3-Clause) is a Rust Valkey-Module which brings a native and sp
44

55
Valkey-Bloom is built using bloomfilter::Bloom (https://crates.io/crates/bloomfilter which has a BSD-2-Clause license).
66

7-
It is compatible with the BloomFilter (BF.*) command APIs of the ReBloom Module from Redis Ltd.
7+
It is compatible with the BloomFilter (BF.*) command APIs in Redis offerings.
88

9-
The following commands are supported.
9+
## Supported commands
1010
```
1111
BF.EXISTS
1212
BF.ADD
@@ -19,99 +19,45 @@ BF.INSERT
1919
BF.LOAD
2020
```
2121

22-
Build instructions for Linux.
22+
## Build instructions
2323
```
2424
curl https://sh.rustup.rs -sSf | sh
2525
sudo yum install clang
26-
git clone https://github.com/KarthikSubbarao/valkey-bloom.git
26+
git clone https://github.com/valkey-io/valkey-bloom.git
2727
cd valkey-bloom
2828
cargo build --all --all-targets --release
2929
valkey-server --loadmodule ./target/release/libvalkey_bloom.so
3030
```
3131

32-
Local development script to build, run format checks, run unit / integration tests, and for cargo release:
32+
#### Local development script to build, run format checks, run unit / integration tests, and for cargo release:
3333
```
3434
# Builds the valkey-server (unstable) for integration testing.
3535
SERVER_VERSION=unstable
3636
./build.sh
37-
# Builds the valkey-server (8.0.0) for integration testing.
37+
# Same as above, but uses valkey-server (8.0.0) for integration testing.
3838
SERVER_VERSION=8.0.0
3939
./build.sh
4040
```
4141

42-
Client Usage
43-
```
44-
<redacted> % ./valkey-cli
45-
127.0.0.1:6379> module list
46-
1) 1) "name"
47-
2) "bloom"
48-
3) "ver"
49-
4) (integer) 1
50-
5) "path"
51-
6) "./target/release/libvalkey_bloom.so"
52-
7) "args"
53-
8) (empty array)
54-
127.0.0.1:6379> bf.add key item
55-
(integer) 1
56-
127.0.0.1:6379> bf.exists key item
57-
(integer) 1
58-
127.0.0.1:6379> bf.exists key item2
59-
(integer) 0
60-
127.0.0.1:6379> bf.card key
61-
(integer) 1
62-
127.0.0.1:6379> bf.reserve key 0.01 10000
63-
(error) ERR item exists
64-
127.0.0.1:6379> bf.reserve key1 0.01 10000
65-
OK
66-
127.0.0.1:6379> bf.card key1
67-
(integer) 0
68-
127.0.0.1:6379> bf.add key1 item
69-
(integer) 1
70-
127.0.0.1:6379> bf.card key1
71-
(integer) 1
72-
```
42+
## Load the Module
43+
To test the module with a Valkey, you can load the module in the following ways:
7344

45+
#### Using valkey.conf:
7446
```
75-
127.0.0.1:6379> bf.reserve key1 0.01 10000
76-
OK
77-
127.0.0.1:6379> bf.info key3
78-
(empty array)
79-
127.0.0.1:6379> bf.info key1
80-
1) Capacity
81-
2) (integer) 10000
82-
3) Size
83-
4) (integer) 12198
84-
5) Number of filters
85-
6) (integer) 1
86-
7) Number of items inserted
87-
8) (integer) 0
88-
9) Expansion rate
89-
10) (integer) 2
47+
1. Add the following to valkey.conf:
48+
loadmodule /path/to/libvalkey_bloom.so
49+
2. Start valkey-server:
50+
valkey-server /path/to/valkey.conf
9051
```
9152

92-
RDB Load, Save and flushall validation
53+
#### Starting Valkey with the `--loadmodule` option:
54+
```text
55+
valkey-server --loadmodule /path/to/libvalkey_bloom.so
9356
```
94-
127.0.0.1:6379> info keyspace
95-
# Keyspace
96-
127.0.0.1:6379> bf.add key item
97-
(integer) 1
98-
127.0.0.1:6379> info keyspace
99-
# Keyspace
100-
db0:keys=1,expires=0,avg_ttl=0
101-
127.0.0.1:6379> flushall
102-
OK
103-
127.0.0.1:6379> info keyspace
104-
# Keyspace
105-
127.0.0.1:6379> bf.add key item
106-
(integer) 1
107-
127.0.0.1:6379> bgsave
108-
Background saving started
109-
127.0.0.1:6379> shutdown
110-
not connected> info keyspace // Started up
111-
# Keyspace
112-
db0:keys=1,expires=0,avg_ttl=0
113-
127.0.0.1:6379> keys *
114-
1) "key"
115-
127.0.0.1:6379> bf.exists key item
116-
(integer) 1
57+
58+
#### Using the Valkey command `MODULE LOAD`:
11759
```
60+
1. Connect to a running Valkey instance using valkey-cli
61+
2. Execute Valkey command:
62+
MODULE LOAD /path/to/libvalkey_bloom.so
63+
```

src/bloom/command_handler.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -565,9 +565,7 @@ pub fn bloom_filter_insert(ctx: &Context, input_args: &[ValkeyString]) -> Valkey
565565
idx += 1;
566566
}
567567
if idx == argc && items_provided {
568-
// We expect the ITEMS <item> [<item> ...] argument to be provided on the BF.INSERT command used on primary nodes.
569-
// For replicated commands, this is optional to allow BF.INSERT to be used to replicate bloom object creation
570-
// commands without any items (BF.RESERVE).
568+
// When the `ITEMS` argument is provided, we expect additional item arg/s to be provided.
571569
return Err(ValkeyError::WrongArity);
572570
}
573571
// If the filter does not exist, create one

0 commit comments

Comments
 (0)