PHPackages                             verdient/bloom-filter - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Search &amp; Filtering](/categories/search)
4. /
5. verdient/bloom-filter

ActiveLibrary[Search &amp; Filtering](/categories/search)

verdient/bloom-filter
=====================

Bloom filter for PHP

0.0.2(5y ago)154MITPHPPHP &gt;=7.0.0

Since May 16Pushed 5y ago1 watchersCompare

[ Source](https://github.com/Verdient/bloom-filter)[ Packagist](https://packagist.org/packages/verdient/bloom-filter)[ Docs](https://github.com/Verdient/bloom-filter)[ RSS](/packages/verdient-bloom-filter/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (2)Versions (4)Used By (0)

Bloom Filter
============

[](#bloom-filter)

布隆过滤器

### 安装

[](#安装)

`composer require verdient/bloom-filter`

### 创建新的过滤器

[](#创建新的过滤器)

```
use Verdient\BloomFilter\BloomFilter;

/**
 * @var bool 是否自动重置
 */
$autoReset = false;

/**
 * @var float 误判率，最大为1，最小为0
 */
$misjudgmentRate = 0.001;

/**
 * @var int 集合大小，默认为false
 */
$setSize = false;

/**
 * @var int 哈希次数，默认为false
 */
$hashCount = false;

/**
 * @var int 预计最大元素数量，默认为1000000
 * autoReset设置为true时有效
 * 当已加入的元素数量大于maxEntries时，会自动重置过滤器
 */
$maxEntries = 1000000;

/**
 * @var string|array 存储组件配置
 * 可选Verdient\BloomFilter\BitMapStorage和Verdient\BloomFilter\RedisStorage
 * 默认为BitMapStorage
 * RedisStorage需配置参数，分别为
 *  'host' => '127.0.0.1', // 默认为127.0.0.1
 *  'password' => null, // 默认为null
 *  'db' => 0, // 默认为0
 *  'key' => null // 默认为null
 * 若需持久化存储二进制向量，需指定key的值，否则每个新创建的BloomFilter
 * 都是全新的过滤器，与以前的结果无关
 * 数组写法为：
 * $storage = [
 *  'class' => 'Verdient\BloomFilter\RedisStorage',
 *  'host' => '127.0.0.1',
 *  'password' => null,
 *  'db' => 0,
 *  'key' => null
 * ];
 */
$storage = 'Verdient\BloomFilter\BitMapStorage';

$filter = new BloomFilter([
	'autoReset' => $autoReset,
	'misjudgmentRate' => $misjudgmentRate,
	'setSize' => $setSize,
	'hashCount ' => $hashCount,
	'maxEntries' => $maxEntries,
	'storage' => $storage
]);
```

### 添加元素

[](#添加元素)

```
$filter->add($value);
```

### 判断元素是否在集合内

[](#判断元素是否在集合内)

```
$result = $filter->has($value);
```

如果result为`true`，则元素`可能`在集合内，否则元素`一定`不在集合内

### 判断元素总数

[](#判断元素总数)

```
$result = $filter->getCount();
```

如果autoReset设置为`true`，总数也会随着重置而重置为0

### 手动重置过滤器

[](#手动重置过滤器)

```
$result = $filter->reset();
```

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~6 days

Total

3

Last Release

2179d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/606eaa4bc61b11fa19f25526a3084758b7086ceb8b11cdbcafd5df11871f2437?d=identicon)[Verdient。](/maintainers/Verdient%E3%80%82)

---

Top Contributors

[![Verdient](https://avatars.githubusercontent.com/u/22468867?v=4)](https://github.com/Verdient "Verdient (5 commits)")

---

Tags

filterBloom Filterbloom

### Embed Badge

![Health badge](/badges/verdient-bloom-filter/health.svg)

```
[![Health](https://phpackages.com/badges/verdient-bloom-filter/health.svg)](https://phpackages.com/packages/verdient-bloom-filter)
```

###  Alternatives

[clue/stream-filter

A simple and modern approach to stream filtering in PHP

1.7k261.7M7](/packages/clue-stream-filter)[pleonasm/bloom-filter

A pure PHP implementation of a Bloom Filter

76745.5k6](/packages/pleonasm-bloom-filter)[laminas/laminas-filter

Programmatically filter and normalize data and files

9428.0M150](/packages/laminas-laminas-filter)[friendsofcake/search

CakePHP Search plugin using PRG pattern

1742.0M37](/packages/friendsofcake-search)[htmlawed/htmlawed

Official htmLawed PHP library for HTML filtering

401.1M9](/packages/htmlawed-htmlawed)[outl1ne/nova-input-filter

An input filter for Laravel Nova

24822.7k](/packages/outl1ne-nova-input-filter)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
