
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.
bloomfilter-redis
Advanced tools
Bloomfilter-redis is a node.js package implementing bloom filter using redis as backend. 🚢
use 32bit murmur3 and FNV-1a for double hashing
depends on redis package
you specify the filter size in redis, up to 512M
npm install bloomfilter-redis
const BloomFilter = require('bloomfilter-redis');
const redis = require("redis");
let bf = new BloomFilter({//all params have a default value, and I choose some to present below
redisSize: 16, // this will create a string value which is 16 MegaBytes in length
hashesNum: 8, // how many hash functions do we use
redisKey: 'test', //this will create a string which keyname is `test`
redisClient: redis.createClient(), //you can choose to create the client by yourself
});
promise = bf.init(); // invokes `SETBIT` to allocate memory in redis.For details https://redis.io/commands/setbit
promise.then(() => {
return bf.add('abc'); // add "abc"
})
.then(() => {
return bf.add('hello'); // add "hello"
})
.then(() => {
return bf.add('world'); // add "world"
})
.then(() => {
return bf.add('nihao'); // add "nihao"
})
.then(() => {
return bf.contains('hola');
})
.then((result) => {
console.log(`"hola" in the set? ${result}`); // "hola" in the set? false
})
.then(() => {
return bf.contains('hello');
})
.then((result) => {
console.log(`"hello" in the set? ${result}`); // "hello" in the set? true
}).catch(function(err) {
console.error(err);
});
Or for an easier way, use promise.all()
const BloomFilter = require('bloomfilter-redis');
const redis = require("redis");
let bf = new BloomFilter();
promise = bf.init();
// both array has `I love you`
arr = ['我爱你', 'I love you', 'je t\'aime', 'ich liebe dich', 'Ti Amo', 'te amo vos amo'];
testArr = ['사랑해요', 'I love you', '爱してる'];
promiseAddArr = [];
promiseContainsArr = [];
arr.forEach(str => {
promiseAddArr.push(bf.add(str)); // assembly add tasks
});
testArr.forEach(str => {
promiseContainsArr.push(bf.contains(str)); // assembly contains tasks
});
//lauch!
Promise.all(promiseAddArr).then(() => {
Promise.all(promiseContainsArr).then(results => {
console.log(results); // [ false, true, false ]. Yeah, that's the right answer
})
});
BloomFilter.init,BloomFilter.add and BloomFilter.contains all returns a Promise.
As there are various options when creating a redis-client using redis.createClient method, it may be a good choice to let users create the redis-client by themselves. Pass the redis-client as a parameter when contructing BloomFilter.
we use redis string as the filter.
A redis string value can be at max 512 Megabytes in length, that is totally 512*2^20*8 bits.
Javascript does not support 64bit integer calculations.
32bit hash is suffient.
MIT
FAQs
A package implementing bloom filter using redis as backend.
We found that bloomfilter-redis demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.