npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@thehenrytsai/redis-bloom

v1.2.2

Published

Redis Bloom filter without needing to load custom modules

Downloads

57

Readme

redis-bloom

This Bloom filter implementation is designed to work with managed Redis services that do not support loading custom modules (like AWS ElastiCache), by relying solely on native Redis bitmap commands to set and check bits.

Basic Usage

import { RedisBloomFilterClient } from "@thehenrytsai/redis-bloom";

// Connect to Redis
const client = await RedisBloomFilterClient.create({
  url: "redis://localhost:6379",
});

// Getting or creating a Bloom filter
const filter = await client.get("my-filter-name");

// Adding items to the filter
await filter.add("[email protected]", "[email protected]");

// Checking which items exist in the filter
const matches = await filter.extractContainedItems(
  "[email protected]", 
  "[email protected]",
  "[email protected]"
);

// `matches` is a Set containing the items that might exist
console.log(matches.has("[email protected]"));  // true
console.log(matches.has("[email protected]")); // false

// Clearing a filter
await client.clear("my-filter-name");

// Clearing all filters (mainly for testing purposes)
await client.clearAll();

// Closing the connection when finished
await client.close();

Advanced Configuration

The Redis Bloom filter can be fine-tuned for your specific use case by adjusting its configuration parameters:

const client = await RedisBloomFilterClient.create({
  url: "rediss://localhost:6379",
  checkServerIdentity: false,     // false to skip cert verification (for testing)
  bloomFilterSizeInBits: 100_000, // defaults to 10,000 bits
  hashesPerItem: 5,               // defaults to 3 hashes per item
  hashFunction1: customHashFn1,
  hashFunction2: customHashFn2,
});

Custom Hash Functions

You can provide your own hash functions for special requirements or better performance. The provided hash functions should:

  • Have the following signature

    (data: string) => Promise<number>
  • Provide uniform distribution across the 32-bit integer range

By default, this library uses SHA-256 slices for the hash functions, but faster alternatives like MurmurHash or xxHash are recommended for production use.

Dev/Contributor Environment Setup

This guide assumes Mac/Linux environment.

  1. Install hermit, a tool for bootstrapping platform/environment level dependencies such as node:

    curl -fsSL https://github.com/cashapp/hermit/releases/download/stable/install.sh | /bin/bash

    This will download and install hermit into ~/bin. You should add this to your $PATH if it isn’t already:

    For Zsh (macOS):

      echo 'export PATH="$HOME/bin:$PATH"' >> ~/.zshrc
      source ~/.zshrc

    For Bash (Linux):

      echo 'export PATH="$HOME/bin:$PATH"' >> ~/.bashrc
      source ~/.bashrc

    See https://cashapp.github.io/hermit/ if you want to learn more.

  2. Activate hermit (always run this command first when you start your IDE or command prompt): . ./bin/activate-hermit

  3. Now you can install the dev environment dependencies using hermit:

    hermit install

Building Node.js bundle

deno task build:node or

npm run build (calls the above deno task)

Appendix

  • To connect to an AWS ElastiCache instance through an EC2 proxy/bastion host:

    • Ensure the EC2 instance's Security Group has been added to allowed Security Groups under ElastiCache's "Connectivity and security" settings.

    • Create SSH tunnel with port forwarding to the ElastiCache:

      ssh -i /path/to/ec2-access-key.pem -N -L <local-port>:<elasticache-endpoint>:<elasticache-port> ec2-user@<public-ec2-instance-ip>

      For example:

      ssh -i ec2-access-key.pem -N -L 6380:master.test-service-valkey.tl83oi.use1.cache.amazonaws.com:6379 [email protected]
    • After establishing the tunnel, connect to ElastiCache locally via rediss://localhost:6380

      NOTE: you'll need to disable server identity check: checkServerIdentity: false when creating the RedisBloomFilterClient.