Research
Security News
Kill Switch Hidden in npm Packages Typosquatting Chalk and Chokidar
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
@redis/bloom
Advanced tools
This package provides support for the [RedisBloom](https://redisbloom.io) module, which adds additional probabilistic data structures to Redis. It extends the [Node Redis client](https://github.com/redis/node-redis) to include functions for each of the R
@redis/bloom is an npm package that provides probabilistic data structures for Redis, such as Bloom filters, Cuckoo filters, Count-Min Sketch, and Top-K. These data structures are useful for efficiently handling large sets of data with minimal memory usage and are often used in scenarios like caching, deduplication, and approximate counting.
Bloom Filter
This example demonstrates how to create a Bloom filter, add an item to it, and check for the existence of an item. Bloom filters are used to test whether an element is a member of a set with a possible false positive rate.
const { createClient } = require('@redis/bloom');
async function bloomFilterExample() {
const client = createClient();
await client.connect();
await client.bf.reserve('myBloom', 0.01, 1000);
await client.bf.add('myBloom', 'item1');
const exists = await client.bf.exists('myBloom', 'item1');
console.log(exists); // true
await client.disconnect();
}
bloomFilterExample();
Cuckoo Filter
This example shows how to create a Cuckoo filter, add an item, and check for its existence. Cuckoo filters are similar to Bloom filters but support deletion of items.
const { createClient } = require('@redis/bloom');
async function cuckooFilterExample() {
const client = createClient();
await client.connect();
await client.cf.reserve('myCuckoo', 1000);
await client.cf.add('myCuckoo', 'item1');
const exists = await client.cf.exists('myCuckoo', 'item1');
console.log(exists); // true
await client.disconnect();
}
cuckooFilterExample();
Count-Min Sketch
This example demonstrates how to initialize a Count-Min Sketch, increment the count of an item, and query the count. Count-Min Sketches are used for approximate frequency counting.
const { createClient } = require('@redis/bloom');
async function countMinSketchExample() {
const client = createClient();
await client.connect();
await client.cms.initByDim('myCMS', 2000, 5);
await client.cms.incrBy('myCMS', 'item1', 5);
const count = await client.cms.query('myCMS', 'item1');
console.log(count); // 5
await client.disconnect();
}
countMinSketchExample();
Top-K
This example shows how to create a Top-K data structure, add items to it, and retrieve the top K items. Top-K is used to maintain a list of the most frequent items.
const { createClient } = require('@redis/bloom');
async function topKExample() {
const client = createClient();
await client.connect();
await client.topk.reserve('myTopK', 3);
await client.topk.add('myTopK', 'item1', 'item2', 'item3', 'item1');
const list = await client.topk.list('myTopK');
console.log(list); // ['item1', 'item2', 'item3']
await client.disconnect();
}
topKExample();
The 'bloom-filter' package provides a simple implementation of Bloom filters in JavaScript. It is less feature-rich compared to @redis/bloom and does not integrate with Redis, making it suitable for in-memory operations only.
The 'cuckoo-filter' package offers a JavaScript implementation of Cuckoo filters. Similar to 'bloom-filter', it does not integrate with Redis and is intended for in-memory use cases.
The 'count-min-sketch' package provides a JavaScript implementation of the Count-Min Sketch data structure. It is useful for approximate frequency counting but lacks the Redis integration provided by @redis/bloom.
This package provides support for the RedisBloom module, which adds additional probabilistic data structures to Redis. It extends the Node Redis client to include functions for each of the RediBloom commands.
To use these extra commands, your Redis server must have the RedisBloom module installed.
RedisBloom provides the following probabilistic data structures:
For complete examples, see bloom-filter.js
, cuckoo-filter.js
, count-min-sketch.js
and topk.js
in the Node Redis examples folder.
FAQs
This package provides support for the [RedisBloom](https://redisbloom.io) module, which adds additional probabilistic data structures to Redis. It extends the [Node Redis client](https://github.com/redis/node-redis) to include functions for each of the R
The npm package @redis/bloom receives a total of 1,852,669 weekly downloads. As such, @redis/bloom popularity was classified as popular.
We found that @redis/bloom 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.
Research
Security News
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.