Update: this project has been suspended and superceded by http://rebloom.io
This is a port of the dablooms library - a scalable, counting, Bloom filter by Justin Hines at Bitly - to a Redis module.
For background, refer to the original README.
redablooms provides all of dabloom's functionality, but stores the data structures in Redis Strings instead of files. Additionally, redablooms provides an automatic means for generating element ids using a sequence or server clock with rounding.
- Build a Redis server with support for modules.
- Build the redablooms module:
make
- To load a module, Start Redis with the
--loadmodule /path/to/module.so
option, add it as a directive to the configuration file or send aMODULE LOAD
command.
Adds one or more elements and their ids to the filter in key
.
If key
doesn't exist, the filter is created with the default capacity (100000) and error rate (0.05).
Elements' id
s are always integers, but can be provided in one of the following ways:
- An unsigned integer 'n' means the literal numeric id 'n'.
- '+[n]' means incrementing the filter's current maximum id by 'n' and using that value. By default 'n' is 1, so you can simply use the '+' sign for the default increment. You can use '+0' to use the current maximum id without incrementing it.
- '/[n]' means the server's clock in milliseconds, divided by 'n', floored and multiplied by 'n'. By default 'n' is 1. This is useful for generating ids based on resolutions other than milliseconds, e.g. '/1000' will provide second resolutions ids, '/60000' is for minute resolution, etc.
Notes about adding multiple elements in a single call:
- The clock is sampled once per call.
- max_id may may be updated once, otherwise an error is returned.
Reply: Integer, the filter's current maximum id.
Removes elements by id from the filter. id
s must be only 'n', '/n' or '+0'.
Reply: Integer, the number of elements removed.
Checks if elem
exists in key
.
Reply: Integer, 1 if the element exists, 0 otherwise.
Initializes a new scaling counting Bloom filter.
Use this to specify other-than-the-default capacity and error rate for the filter.
Reply: String, "OK".
Shows the filter's meta data.
Reply: Array.
Adds one or more elements the filter in key
.
If the key doesn't exist, the filter is created with the default capacity (100000) and error rate (0.05).
Reply: Integer, the count of elements in the filter.
Removes elements from the filter.
Reply: Integer, the count of elements in the filter.
Checks if elem
exists in key
.
Reply: Integer, 1 if the element exists, 0 otherwise.
Initializes a new counting Bloom filter.
Use this to specify other-than-the-default capacity and error rate for the filter.
Reply: String, "OK".
Shows the filter's meta data.
Reply: Array.
- Handle counter overflow/0 decrement - silently ignored
- Configurable counter width
Issue reports, pull and feature requests are welcome.
redablooms is licensed under AGPLv3 - see LICENSE.
deblooms is licensed under a very liberal license - see LICENSE-dablooms.