PHPackages                             palicao/php-rebloom - 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. [Caching](/categories/caching)
4. /
5. palicao/php-rebloom

ActiveLibrary[Caching](/categories/caching)

palicao/php-rebloom
===================

0.2.1(5y ago)227.6k↓42.3%4[2 issues](https://github.com/palicao/phpRebloom/issues)MITPHPPHP &gt;=7.2.0CI failing

Since Dec 11Pushed 5y ago2 watchersCompare

[ Source](https://github.com/palicao/phpRebloom)[ Packagist](https://packagist.org/packages/palicao/php-rebloom)[ RSS](/packages/palicao-php-rebloom/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (2)Versions (6)Used By (0)

PhpRebloom
==========

[](#phprebloom)

Use [Redis Bloom](https://oss.redislabs.com/redisbloom/) with PHP!

[![Code Climate maintainability](https://camo.githubusercontent.com/9f1515f3666a62318a068e76b2c6858889f3228e0e869a210f69cf47a12fd641/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636c696d6174652f636f7665726167652d6c65747465722f70616c6963616f2f7068705265626c6f6f6d3f6c6162656c3d6d61696e7461696e6162696c697479266c6f676f3d636f64652d636c696d617465)](https://codeclimate.com/github/palicao/phpRebloom)[![Code Climate coverage](https://camo.githubusercontent.com/1a89116f75d3227007b06d9148f59e02538ccf088393a47b0eeb042239f65709/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636c696d6174652f636f7665726167652f70616c6963616f2f7068705265626c6f6f6d3f6c6f676f3d636f64652d636c696d617465)](https://codeclimate.com/github/palicao/phpRebloom)[![Build Status](https://camo.githubusercontent.com/1b434aa67997b1ebf8979dbb3a931c56107142cb87c3966510ab71a5ac797613/68747470733a2f2f7472617669732d63692e636f6d2f70616c6963616f2f7068705265626c6f6f6d2e7376673f6272616e63683d6d6173746572)](https://travis-ci.com/palicao/phpRebloom)[![Latest Stable Version](https://camo.githubusercontent.com/70c9030793f13af60c4e0831fe4d26735efd37aba3ae9cc5830b1688bebac46e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f70616c6963616f2f7068702d7265626c6f6f6d2e737667)](https://packagist.org/packages/palicao/php-rebloom)[![PHP version](https://camo.githubusercontent.com/ff1906c18de224cb3fb84c95989803cb301b121be9f6933b45e228bd9cc985d9/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f70616c6963616f2f7068702d7265626c6f6f6d2f302e312e30)](https://camo.githubusercontent.com/ff1906c18de224cb3fb84c95989803cb301b121be9f6933b45e228bd9cc985d9/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f70616c6963616f2f7068702d7265626c6f6f6d2f302e312e30)[![GitHub](https://camo.githubusercontent.com/c76c84e24f9f12535705b4ba3e341231426d8c4cb72353768b596b9d3889b0dd/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f70616c6963616f2f7068705265626c6f6f6d)](https://github.com/palicao/phpRebloom/blob/master/LICENSE)

Disclaimer: this is a very lightweight library. For a battery-included experience, please checkout:

Install
-------

[](#install)

`composer require palicao/php-rebloom`

Bloom Filter
------------

[](#bloom-filter)

A Bloom filter is a space-efficient probabilistic data structure designed to determine whether an element is present in a set. False positives are possible.

```
$bloomFilter = new BloomFilter(
    new RedisClient(
        new Redis(),
        new RedisConnectionParams($host, $port)
    )
);

```

### `reserve`

[](#reserve)

`BloomFilter::reserve(string $key, float $error, int $capacity): bool`

Creates an empty Bloom Filter with a given desired error ratio and initial capacity.

See [https://oss.redislabs.com/redisbloom/Bloom\_Commands/#bfreserve](https://oss.redislabs.com/redisbloom/Bloom_Commands/#bfreserve).

### `insert`

[](#insert)

`BloomFilter::insert(string $key, string $value, ?float $error = null, ?int $capacity = null): bool`

Adds an item to the Bloom Filter, creating the filter if it does not yet exist.

See [https://oss.redislabs.com/redisbloom/Bloom\_Commands/#bfadd](https://oss.redislabs.com/redisbloom/Bloom_Commands/#bfadd) and [https://oss.redislabs.com/redisbloom/Bloom\_Commands/#bfinsert](https://oss.redislabs.com/redisbloom/Bloom_Commands/#bfinsert).

### `insertMany`

[](#insertmany)

`BloomFilter::insertMany(string $key, array $values, ?float $error = null, ?int $capacity = null): bool[]`

Adds several items to the BloomFilter, creating the filter if it does not yet exist.

See [https://oss.redislabs.com/redisbloom/Bloom\_Commands/#bfmadd](https://oss.redislabs.com/redisbloom/Bloom_Commands/#bfmadd) and [https://oss.redislabs.com/redisbloom/Bloom\_Commands/#bfinsert](https://oss.redislabs.com/redisbloom/Bloom_Commands/#bfinsert).

### `insertIfKeyExists`

[](#insertifkeyexists)

`BloomFilter::insertIfKeyExists(string $key, string $value): bool`

Adds an item to the Bloom Filter, only if the filter already exists.

See [https://oss.redislabs.com/redisbloom/Bloom\_Commands/#bfadd](https://oss.redislabs.com/redisbloom/Bloom_Commands/#bfadd) and [https://oss.redislabs.com/redisbloom/Bloom\_Commands/#bfinsert](https://oss.redislabs.com/redisbloom/Bloom_Commands/#bfinsert).

### `insertManyIfKeyExists`

[](#insertmanyifkeyexists)

`BloomFilter::insertManyIfKeyExists(string $key, array $values): bool[]`

Adds several items to the Bloom Filter, only if the filter already exists.

See [https://oss.redislabs.com/redisbloom/Bloom\_Commands/#bfadd](https://oss.redislabs.com/redisbloom/Bloom_Commands/#bfadd) and [https://oss.redislabs.com/redisbloom/Bloom\_Commands/#bfinsert](https://oss.redislabs.com/redisbloom/Bloom_Commands/#bfinsert).

### `exists`

[](#exists)

`BloomFilter::exists(string $key, string $value): bool`

Checks if an item exists.

See [https://oss.redislabs.com/redisbloom/Bloom\_Commands/#bfadd](https://oss.redislabs.com/redisbloom/Bloom_Commands/#bfadd).

### `manyExist`

[](#manyexist)

`BloomFilter::manyExist(string $key, array $values): bool[]`

Checks if many items exist.

See [https://oss.redislabs.com/redisbloom/Bloom\_Commands/#bfmexists](https://oss.redislabs.com/redisbloom/Bloom_Commands/#bfmexists).

### `scanDump`, `loadChunks` and `copy`

[](#scandump-loadchunks-and-copy)

`BloomFilter::scanDump(string $key): array``BloomFilter::loadChunks(string $key, array $chunks): void``BloomFilter::copy(string $sourceKey, string $destKey): void`

`scanDump` exports the whole Bloom Filter in an array, which can be loaded in chunks by `loadChunks`. The `copy` function, using the previous 2 functions, allows to quickly copy one Bloom Filter to a different key.

See [https://oss.redislabs.com/redisbloom/Bloom\_Commands/#bfscandump](https://oss.redislabs.com/redisbloom/Bloom_Commands/#bfscandump) and [https://oss.redislabs.com/redisbloom/Bloom\_Commands/#bfloadchunk](https://oss.redislabs.com/redisbloom/Bloom_Commands/#bfloadchunk).

Cuckoo Filter
-------------

[](#cuckoo-filter)

Cuckoo filter is similar to Bloom Filter, but it's even more space-efficient and allows deleting items.

```
$cuckooFilter = new CuckooFilter(
    new RedisClient(
        new Redis(),
        new RedisConnectionParams($host, $port)
    )
);

```

### `reserve`

[](#reserve-1)

`CuckooFilter::reserve(string $key, int $capacity, ?int $bucketSize = null, ?int $maxIterations = null, ?int $expansion = null): bool`

Create an empty cuckoo filter with an initial capacity. The false positive rate is fixed at about 3%, depending on how full the filter is.

See [https://oss.redislabs.com/redisbloom/Cuckoo\_Commands/#cfreserve](https://oss.redislabs.com/redisbloom/Cuckoo_Commands/#cfreserve).

### `insert`

[](#insert-1)

`CuckooFilter::insert(string $key, string $value, bool $allowDuplicateValues = true, ?int $capacity = null): bool`

Adds an item to the cuckoo filter, creating the filter if it does not exist.

See [https://oss.redislabs.com/redisbloom/Cuckoo\_Commands/#cfadd](https://oss.redislabs.com/redisbloom/Cuckoo_Commands/#cfadd), [https://oss.redislabs.com/redisbloom/Cuckoo\_Commands/#cfaddnx](https://oss.redislabs.com/redisbloom/Cuckoo_Commands/#cfaddnx), [https://oss.redislabs.com/redisbloom/Cuckoo\_Commands/#cfinsert](https://oss.redislabs.com/redisbloom/Cuckoo_Commands/#cfinsert), [https://oss.redislabs.com/redisbloom/Cuckoo\_Commands/#cfinsertnx](https://oss.redislabs.com/redisbloom/Cuckoo_Commands/#cfinsertnx).

### `insertMany`

[](#insertmany-1)

`CuckooFilter::insertMany(string $key, array $values, bool $allowDuplicateValues = true, ?int $capacity = null): bool[]`

Similar to the previous, adds many values to the key.

See [https://oss.redislabs.com/redisbloom/Cuckoo\_Commands/#cfadd](https://oss.redislabs.com/redisbloom/Cuckoo_Commands/#cfadd), [https://oss.redislabs.com/redisbloom/Cuckoo\_Commands/#cfaddnx](https://oss.redislabs.com/redisbloom/Cuckoo_Commands/#cfaddnx), [https://oss.redislabs.com/redisbloom/Cuckoo\_Commands/#cfinsert](https://oss.redislabs.com/redisbloom/Cuckoo_Commands/#cfinsert), [https://oss.redislabs.com/redisbloom/Cuckoo\_Commands/#cfinsertnx](https://oss.redislabs.com/redisbloom/Cuckoo_Commands/#cfinsertnx).

### `insertIfKeyExists`

[](#insertifkeyexists-1)

`CuckooFilter::insertIfKeyExists(string $key, string $value, bool $allowDuplicateValues = true, ?int $capacity = null): bool`

Inserts an item in a cuckoo filter, only if it exists.

See [https://oss.redislabs.com/redisbloom/Cuckoo\_Commands/#cfadd](https://oss.redislabs.com/redisbloom/Cuckoo_Commands/#cfadd), [https://oss.redislabs.com/redisbloom/Cuckoo\_Commands/#cfaddnx](https://oss.redislabs.com/redisbloom/Cuckoo_Commands/#cfaddnx), [https://oss.redislabs.com/redisbloom/Cuckoo\_Commands/#cfinsert](https://oss.redislabs.com/redisbloom/Cuckoo_Commands/#cfinsert), [https://oss.redislabs.com/redisbloom/Cuckoo\_Commands/#cfinsertnx](https://oss.redislabs.com/redisbloom/Cuckoo_Commands/#cfinsertnx).

### `insertManyIfKeyExists`

[](#insertmanyifkeyexists-1)

`CuckooFilter::insertManyIfKeyExists(string $key, array $values, bool $allowDuplicateValues = true, ?int $capacity = null): bool[]`

Inserts many items in a cuckoo filter, only if it exists.

See [https://oss.redislabs.com/redisbloom/Cuckoo\_Commands/#cfadd](https://oss.redislabs.com/redisbloom/Cuckoo_Commands/#cfadd), [https://oss.redislabs.com/redisbloom/Cuckoo\_Commands/#cfaddnx](https://oss.redislabs.com/redisbloom/Cuckoo_Commands/#cfaddnx), [https://oss.redislabs.com/redisbloom/Cuckoo\_Commands/#cfinsert](https://oss.redislabs.com/redisbloom/Cuckoo_Commands/#cfinsert), [https://oss.redislabs.com/redisbloom/Cuckoo\_Commands/#cfinsertnx](https://oss.redislabs.com/redisbloom/Cuckoo_Commands/#cfinsertnx).

### `exists`

[](#exists-1)

`CuckooFilter::exists(string $key, string $value): bool`

Returns true if a cuckoo filter exists.

See [https://oss.redislabs.com/redisbloom/Cuckoo\_Commands/#cfexists](https://oss.redislabs.com/redisbloom/Cuckoo_Commands/#cfexists).

### `delete`

[](#delete)

`CuckooFilter::delete(string $key, string $value): bool`

Deletes an item once in a filter.

See [https://oss.redislabs.com/redisbloom/Cuckoo\_Commands/#cfdel](https://oss.redislabs.com/redisbloom/Cuckoo_Commands/#cfdel).

### `count`

[](#count)

`CuckooFilter::count(string $key, string $value): int`

Returns the number of times an item may be in the filter.

See [https://oss.redislabs.com/redisbloom/Cuckoo\_Commands/#cfcount](https://oss.redislabs.com/redisbloom/Cuckoo_Commands/#cfcount).

### `scanDump`, `loadChunks` and `copy`

[](#scandump-loadchunks-and-copy-1)

`CuckooFilter::scanDump(string $key): array``CuckooFilter::loadChunks(string $key, array $chunks): void``CuckooFilter::copy(string $sourceKey, string $destKey): void`

`scanDump` exports the whole Cuckoo Filter in an array, which can be loaded in chunks by `loadChunks`. The `copy` function, using the previous 2 functions, allows to quickly copy one Cuckoo Filter to a different key.

CountMinSketch
--------------

[](#countminsketch)

Count-Min Sketch is a probabilistic data structure that serves as a frequency table of events in a stream of data.

```
$countMinSketch = new CountMinSketch(
    new RedisClient(
        new Redis(),
        new RedisConnectionParams($host, $port)
    )
);

```

### `initByDimensions`

[](#initbydimensions)

`CountMinSketch::initByDimensions(string $key, int $width, int $depth): bool`

Initializes a CountMinSketch named `$key` with the `$width` and `$depth` provided by the user.

See [https://oss.redislabs.com/redisbloom/CountMinSketch\_Commands/#cmsinitbydim](https://oss.redislabs.com/redisbloom/CountMinSketch_Commands/#cmsinitbydim).

### `initByProbability`

[](#initbyprobability)

`CountMinSketch::initByProbability(string $key, float $error, float $probability): bool`

Initializes a CountMinSketch to accommodate the desired error rate and probability for inflated count.

See [https://oss.redislabs.com/redisbloom/CountMinSketch\_Commands/#cmsinitbyprob](https://oss.redislabs.com/redisbloom/CountMinSketch_Commands/#cmsinitbyprob).

### `incrementBy`

[](#incrementby)

`CountMinSketch::incrementBy(string $key, Pair ...$pairs): bool`

Increments one or more items by a given value in a CountMinSketch. A `Pair` represents an item and the value we want to increment.

See [https://oss.redislabs.com/redisbloom/CountMinSketch\_Commands/#cmsincrby](https://oss.redislabs.com/redisbloom/CountMinSketch_Commands/#cmsincrby).

### `query`

[](#query)

`CountMinSketch::query(string $key, string ... $items): Pair[]`

Returns the approximate count for one or more items.

See [https://oss.redislabs.com/redisbloom/CountMinSketch\_Commands/#cmsquery](https://oss.redislabs.com/redisbloom/CountMinSketch_Commands/#cmsquery).

### `merge`

[](#merge)

Merges multiple CountMinSketches into one, so that the value for each item is the sum of the values in each sketch. The `$sourceKeysWeightMap` is an associative array where each key is a sketch, and the value is the weight, that is the value we want each item count to be multiplied by before merging.

`CountMinSketch::merge(string $destinationKey, array $sourceKeysWeightMap) : bool`

See [https://oss.redislabs.com/redisbloom/CountMinSketch\_Commands/#cmsmerge](https://oss.redislabs.com/redisbloom/CountMinSketch_Commands/#cmsmerge).

### `info`

[](#info)

Returns an instance of CountMinSketchInfo, which contains information regarding width, depth and total count of the sketch.

`CountMinSketch::info(string $key): CountMinSketchInfo`

See [https://oss.redislabs.com/redisbloom/CountMinSketch\_Commands/#cmsinfo](https://oss.redislabs.com/redisbloom/CountMinSketch_Commands/#cmsinfo).

TopK
----

[](#topk)

Similar to CountMinSketch, is based on the algorithm described here:

### `reserve`

[](#reserve-2)

`TopK::reserve(string $key, int $topK, int $width, int $depth, float $decay): bool`

Reserves a TopK suitable to calculate `$topK` top elements, with a given `$width` and `$depth` and with a specified `$decay` (probability of reducing a counter in an occupied bucket).

See [https://oss.redislabs.com/redisbloom/TopK\_Commands/#topkreserve](https://oss.redislabs.com/redisbloom/TopK_Commands/#topkreserve).

### `add`

[](#add)

Adds one or more item to the TooK. If an item enters the Top-K list, the item which is expelled is returned in the position that was occupied by the added item that took its place in the Top-K.

`TopK::add(string $key, string ... $items): array`

See [https://oss.redislabs.com/redisbloom/TopK\_Commands/#topkadd](https://oss.redislabs.com/redisbloom/TopK_Commands/#topkadd).

### `incrementBy`

[](#incrementby-1)

Increase the score of an item in the data structure by increment. Similar to `add`, expelled items are returned.

`TopK::incrementBy(string $key, Pair ...$pairs): array`

See [https://oss.redislabs.com/redisbloom/TopK\_Commands/#topkincrby](https://oss.redislabs.com/redisbloom/TopK_Commands/#topkincrby).

### `query`

[](#query-1)

Returns subset of $items containing the elements found in the Top-K.

`TopK::query(string $key, string ... $items): string[]`

See [https://oss.redislabs.com/redisbloom/TopK\_Commands/#topkquery](https://oss.redislabs.com/redisbloom/TopK_Commands/#topkquery).

### `count`

[](#count-1)

Returns a subset of $items containing the elements found in the top-k with their approximate count.

`TopK::count(string $key, string ... $items): Pair[]`

See [https://oss.redislabs.com/redisbloom/TopK\_Commands/#topkcount](https://oss.redislabs.com/redisbloom/TopK_Commands/#topkcount).

### `list`

[](#list)

Returns the top-k items with their relative position.

`TopK::list(string $key): Pair[]`

See [https://oss.redislabs.com/redisbloom/TopK\_Commands/#topklist](https://oss.redislabs.com/redisbloom/TopK_Commands/#topklist).

### `info`

[](#info-1)

Returns a TopKInfo object containing information about size, with, depth and decay of the Top-K

`TopK::info(string $key): TopKInfo`

See [https://oss.redislabs.com/redisbloom/TopK\_Commands/#topkinfo](https://oss.redislabs.com/redisbloom/TopK_Commands/#topkinfo).

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity34

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity46

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 ~160 days

Total

3

Last Release

2029d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/29f2d2fba3b6f3b89c90f2d222ae67e62663a98b1fb8fd67bbfaa489da21e65e?d=identicon)[palicao](/maintainers/palicao)

---

Top Contributors

[![palicao](https://avatars.githubusercontent.com/u/659961?v=4)](https://github.com/palicao "palicao (17 commits)")

---

Tags

bloom-filtercount-min-sketchcuckoo-filterdriverphpphp-redispredisredisredis-servertop-k

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm

Type Coverage Yes

### Embed Badge

![Health badge](/badges/palicao-php-rebloom/health.svg)

```
[![Health](https://phpackages.com/badges/palicao-php-rebloom/health.svg)](https://phpackages.com/packages/palicao-php-rebloom)
```

###  Alternatives

[react/cache

Async, Promise-based cache interface for ReactPHP

444112.4M40](/packages/react-cache)[wp-media/wp-rocket

Performance optimization plugin for WordPress

7431.3M3](/packages/wp-media-wp-rocket)[illuminate/cache

The Illuminate Cache package.

12835.6M1.4k](/packages/illuminate-cache)[colinmollenhour/php-redis-session-abstract

A Redis-based session handler with optimistic locking

6325.6M14](/packages/colinmollenhour-php-redis-session-abstract)[cheprasov/php-redis-client

Php client for Redis. It is a fast, fully-functional and user-friendly client for Redis, optimized for performance. RedisClient supports the latest versions of Redis starting from 2.6 to 6.0

1281.2M21](/packages/cheprasov-php-redis-client)[amphp/redis

Efficient asynchronous communication with Redis servers, enabling scalable and responsive data storage and retrieval.

165634.7k44](/packages/amphp-redis)

PHPackages © 2026

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