{"id":28671002,"url":"https://github.com/palicao/phprebloom","last_synced_at":"2025-06-13T18:39:00.267Z","repository":{"id":56635339,"uuid":"220708399","full_name":"palicao/phpRebloom","owner":"palicao","description":"🎛️ Use RedisBloom in PHP!","archived":false,"fork":false,"pushed_at":"2021-04-26T20:12:30.000Z","size":87,"stargazers_count":21,"open_issues_count":2,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-30T08:50:43.318Z","etag":null,"topics":["bloom-filter","count-min-sketch","cuckoo-filter","driver","php","php-redis","predis","redis","redis-server","top-k"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/palicao.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-11-09T21:52:16.000Z","updated_at":"2023-04-27T08:41:35.000Z","dependencies_parsed_at":"2022-08-15T22:20:30.010Z","dependency_job_id":null,"html_url":"https://github.com/palicao/phpRebloom","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/palicao/phpRebloom","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/palicao%2FphpRebloom","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/palicao%2FphpRebloom/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/palicao%2FphpRebloom/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/palicao%2FphpRebloom/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/palicao","download_url":"https://codeload.github.com/palicao/phpRebloom/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/palicao%2FphpRebloom/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259700022,"owners_count":22898367,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bloom-filter","count-min-sketch","cuckoo-filter","driver","php","php-redis","predis","redis","redis-server","top-k"],"created_at":"2025-06-13T18:38:48.819Z","updated_at":"2025-06-13T18:39:00.255Z","avatar_url":"https://github.com/palicao.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PhpRebloom\n\nUse [Redis Bloom](https://oss.redislabs.com/redisbloom/) with PHP!\n\n[![Code Climate maintainability](https://img.shields.io/codeclimate/coverage-letter/palicao/phpRebloom?label=maintainability\u0026logo=code-climate)](https://codeclimate.com/github/palicao/phpRebloom)\n[![Code Climate coverage](https://img.shields.io/codeclimate/coverage/palicao/phpRebloom?logo=code-climate)](https://codeclimate.com/github/palicao/phpRebloom)\n[![Build Status](https://travis-ci.com/palicao/phpRebloom.svg?branch=master)](https://travis-ci.com/palicao/phpRebloom)\n[![Latest Stable Version](https://img.shields.io/packagist/v/palicao/php-rebloom.svg)](https://packagist.org/packages/palicao/php-rebloom)\n[![PHP version](https://img.shields.io/packagist/php-v/palicao/php-rebloom/0.1.0)]((https://packagist.org/packages/palicao/php-rebloom))\n[![GitHub](https://img.shields.io/github/license/palicao/phpRebloom)](https://github.com/palicao/phpRebloom/blob/master/LICENSE)\n\nDisclaimer: this is a very lightweight library. For a battery-included experience,\nplease checkout: https://github.com/averias/phpredis-bloom\n\n## Install\n`composer require palicao/php-rebloom`\n\n## Bloom Filter\n\nA Bloom filter is a space-efficient probabilistic data structure designed to determine\nwhether an element is present in a set. False positives are possible.\n\n```\n$bloomFilter = new BloomFilter(\n    new RedisClient(\n        new Redis(),\n        new RedisConnectionParams($host, $port)\n    )\n);\n```\n\n### `reserve`\n\n`BloomFilter::reserve(string $key, float $error, int $capacity): bool`\n\nCreates an empty Bloom Filter with a given desired error ratio and initial capacity.\n\nSee https://oss.redislabs.com/redisbloom/Bloom_Commands/#bfreserve.\n\n### `insert`\n\n`BloomFilter::insert(string $key, string $value, ?float $error = null, ?int $capacity = null): bool`\n\nAdds an item to the Bloom Filter, creating the filter if it does not yet exist.\n\nSee https://oss.redislabs.com/redisbloom/Bloom_Commands/#bfadd and https://oss.redislabs.com/redisbloom/Bloom_Commands/#bfinsert.\n\n### `insertMany`\n\n`BloomFilter::insertMany(string $key, array $values, ?float $error = null, ?int $capacity = null): bool[]`\n\nAdds several items to the BloomFilter, creating the filter if it does not yet exist.\n\nSee https://oss.redislabs.com/redisbloom/Bloom_Commands/#bfmadd and https://oss.redislabs.com/redisbloom/Bloom_Commands/#bfinsert.\n\n### `insertIfKeyExists`\n\n`BloomFilter::insertIfKeyExists(string $key, string $value): bool`\n\nAdds an item to the Bloom Filter, only if the filter already exists.\n\nSee https://oss.redislabs.com/redisbloom/Bloom_Commands/#bfadd and https://oss.redislabs.com/redisbloom/Bloom_Commands/#bfinsert.\n\n### `insertManyIfKeyExists`\n\n`BloomFilter::insertManyIfKeyExists(string $key, array $values): bool[]`\n\nAdds several items to the Bloom Filter, only if the filter already exists.\n\nSee https://oss.redislabs.com/redisbloom/Bloom_Commands/#bfadd and https://oss.redislabs.com/redisbloom/Bloom_Commands/#bfinsert.\n\n### `exists`\n\n`BloomFilter::exists(string $key, string $value): bool`\n\nChecks if an item exists.\n\nSee https://oss.redislabs.com/redisbloom/Bloom_Commands/#bfadd.\n\n### `manyExist`\n\n`BloomFilter::manyExist(string $key, array $values): bool[]`\n\nChecks if many items exist.\n\nSee https://oss.redislabs.com/redisbloom/Bloom_Commands/#bfmexists.\n\n### `scanDump`, `loadChunks` and `copy`\n\n`BloomFilter::scanDump(string $key): array`\n`BloomFilter::loadChunks(string $key, array $chunks): void`\n`BloomFilter::copy(string $sourceKey, string $destKey): void`\n\n`scanDump` exports the whole Bloom Filter in an array, which can be loaded in chunks by\n`loadChunks`. The `copy` function, using the previous 2 functions, allows to quickly\ncopy one Bloom Filter to a different key.\n\nSee https://oss.redislabs.com/redisbloom/Bloom_Commands/#bfscandump and https://oss.redislabs.com/redisbloom/Bloom_Commands/#bfloadchunk.\n\n## Cuckoo Filter\n\nCuckoo filter is similar to Bloom Filter, but it's even more space-efficient and allows deleting items.\n\n```\n$cuckooFilter = new CuckooFilter(\n    new RedisClient(\n        new Redis(),\n        new RedisConnectionParams($host, $port)\n    )\n);\n```\n\n### `reserve`\n\n`CuckooFilter::reserve(string $key, int $capacity, ?int $bucketSize = null, ?int $maxIterations = null, ?int $expansion = null): bool`\n\nCreate an empty cuckoo filter with an initial capacity. The false positive rate is fixed at about 3%, depending on how full the filter is.\n\nSee https://oss.redislabs.com/redisbloom/Cuckoo_Commands/#cfreserve.\n\n### `insert`\n\n`CuckooFilter::insert(string $key, string $value, bool $allowDuplicateValues = true, ?int $capacity = null): bool`\n\nAdds an item to the cuckoo filter, creating the filter if it does not exist.\n\nSee https://oss.redislabs.com/redisbloom/Cuckoo_Commands/#cfadd, \nhttps://oss.redislabs.com/redisbloom/Cuckoo_Commands/#cfaddnx,\nhttps://oss.redislabs.com/redisbloom/Cuckoo_Commands/#cfinsert,\nhttps://oss.redislabs.com/redisbloom/Cuckoo_Commands/#cfinsertnx.\n\n### `insertMany`\n\n`CuckooFilter::insertMany(string $key, array $values, bool $allowDuplicateValues = true, ?int $capacity = null): bool[]`\n\nSimilar to the previous, adds many values to the key.\n\nSee https://oss.redislabs.com/redisbloom/Cuckoo_Commands/#cfadd, \nhttps://oss.redislabs.com/redisbloom/Cuckoo_Commands/#cfaddnx,\nhttps://oss.redislabs.com/redisbloom/Cuckoo_Commands/#cfinsert,\nhttps://oss.redislabs.com/redisbloom/Cuckoo_Commands/#cfinsertnx.\n\n### `insertIfKeyExists`\n\n`CuckooFilter::insertIfKeyExists(string $key, string $value, bool $allowDuplicateValues = true, ?int $capacity = null): bool`\n\nInserts an item in a cuckoo filter, only if it exists.\n\nSee https://oss.redislabs.com/redisbloom/Cuckoo_Commands/#cfadd, \nhttps://oss.redislabs.com/redisbloom/Cuckoo_Commands/#cfaddnx,\nhttps://oss.redislabs.com/redisbloom/Cuckoo_Commands/#cfinsert,\nhttps://oss.redislabs.com/redisbloom/Cuckoo_Commands/#cfinsertnx.\n\n### `insertManyIfKeyExists`\n\n`CuckooFilter::insertManyIfKeyExists(string $key, array $values, bool $allowDuplicateValues = true, ?int $capacity = null): bool[]`\n\nInserts many items in a cuckoo filter, only if it exists.\n\nSee https://oss.redislabs.com/redisbloom/Cuckoo_Commands/#cfadd, \nhttps://oss.redislabs.com/redisbloom/Cuckoo_Commands/#cfaddnx,\nhttps://oss.redislabs.com/redisbloom/Cuckoo_Commands/#cfinsert,\nhttps://oss.redislabs.com/redisbloom/Cuckoo_Commands/#cfinsertnx.\n\n### `exists`\n\n`CuckooFilter::exists(string $key, string $value): bool`\n\nReturns true if a cuckoo filter exists.\n\nSee https://oss.redislabs.com/redisbloom/Cuckoo_Commands/#cfexists.\n\n### `delete`\n\n`CuckooFilter::delete(string $key, string $value): bool`\n\nDeletes an item once in a filter.\n\nSee https://oss.redislabs.com/redisbloom/Cuckoo_Commands/#cfdel.\n\n### `count`\n\n`CuckooFilter::count(string $key, string $value): int`\n\nReturns the number of times an item may be in the filter.\n\nSee https://oss.redislabs.com/redisbloom/Cuckoo_Commands/#cfcount.\n\n### `scanDump`, `loadChunks` and `copy`\n\n`CuckooFilter::scanDump(string $key): array`\n`CuckooFilter::loadChunks(string $key, array $chunks): void`\n`CuckooFilter::copy(string $sourceKey, string $destKey): void`\n\n`scanDump` exports the whole Cuckoo Filter in an array, which can be loaded in chunks by\n`loadChunks`. The `copy` function, using the previous 2 functions, allows to quickly\ncopy one Cuckoo Filter to a different key.\n\n## CountMinSketch\n\nCount-Min Sketch is a probabilistic data structure that serves as a frequency table of events in a stream of data. \n\n```\n$countMinSketch = new CountMinSketch(\n    new RedisClient(\n        new Redis(),\n        new RedisConnectionParams($host, $port)\n    )\n);\n```\n\n### `initByDimensions`\n\n`CountMinSketch::initByDimensions(string $key, int $width, int $depth): bool`\n\nInitializes a CountMinSketch named `$key` with the `$width` and `$depth` provided by the user.\n\nSee https://oss.redislabs.com/redisbloom/CountMinSketch_Commands/#cmsinitbydim.\n\n### `initByProbability`\n\n`CountMinSketch::initByProbability(string $key, float $error, float $probability): bool`\n\nInitializes a CountMinSketch to accommodate the desired error rate and probability for inflated count. \n\nSee https://oss.redislabs.com/redisbloom/CountMinSketch_Commands/#cmsinitbyprob.\n\n### `incrementBy`\n\n`CountMinSketch::incrementBy(string $key, Pair ...$pairs): bool`\n\nIncrements one or more items by a given value in a CountMinSketch. A `Pair` represents an item and the value we want to increment.\n\nSee https://oss.redislabs.com/redisbloom/CountMinSketch_Commands/#cmsincrby.\n\n### `query`\n\n`CountMinSketch::query(string $key, string ... $items): Pair[]`\n\nReturns the approximate count for one or more items.\n\nSee https://oss.redislabs.com/redisbloom/CountMinSketch_Commands/#cmsquery.\n\n### `merge`\n\nMerges multiple CountMinSketches into one, so that the value for each item is the sum\nof the values in each sketch. The `$sourceKeysWeightMap` is an associative array\nwhere each key is a sketch, and the value is the weight, that is the value we want\neach item count to be multiplied by before merging.\n\n`CountMinSketch::merge(string $destinationKey, array $sourceKeysWeightMap) : bool`\n\nSee https://oss.redislabs.com/redisbloom/CountMinSketch_Commands/#cmsmerge.\n\n### `info`\n\nReturns an instance of CountMinSketchInfo, which contains information regarding width, depth and total count of the sketch.\n\n`CountMinSketch::info(string $key): CountMinSketchInfo`\n\nSee https://oss.redislabs.com/redisbloom/CountMinSketch_Commands/#cmsinfo.\n\n## TopK\n\nSimilar to CountMinSketch, is based on the algorithm described here: https://www.usenix.org/conference/atc18/presentation/gong\n\n### `reserve`\n\n`TopK::reserve(string $key, int $topK, int $width, int $depth, float $decay): bool`\n\nReserves a TopK suitable to calculate `$topK` top elements, with a given `$width` and `$depth` and with \na specified `$decay` (probability of reducing a counter in an occupied bucket).\n\nSee https://oss.redislabs.com/redisbloom/TopK_Commands/#topkreserve.\n\n### `add`\n\nAdds 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\nthat was occupied by the added item that took its place in the Top-K.\n\n`TopK::add(string $key, string ... $items): array`\n\nSee https://oss.redislabs.com/redisbloom/TopK_Commands/#topkadd.\n\n### `incrementBy`\n\nIncrease the score of an item in the data structure by increment. Similar to `add`, expelled items are returned.\n\n`TopK::incrementBy(string $key, Pair ...$pairs): array`\n\nSee https://oss.redislabs.com/redisbloom/TopK_Commands/#topkincrby.\n\n### `query`\n\nReturns subset of $items containing the elements found in the Top-K.\n\n`TopK::query(string $key, string ... $items): string[]`\n\nSee https://oss.redislabs.com/redisbloom/TopK_Commands/#topkquery.\n\n### `count`\n\nReturns a subset of $items containing the elements found in the top-k with their approximate count.\n\n`TopK::count(string $key, string ... $items): Pair[]`\n\nSee https://oss.redislabs.com/redisbloom/TopK_Commands/#topkcount.\n\n### `list`\n\nReturns the top-k items with their relative position.\n\n`TopK::list(string $key): Pair[]`\n\nSee https://oss.redislabs.com/redisbloom/TopK_Commands/#topklist.\n\n### `info`\n\nReturns a TopKInfo object containing information about size, with, depth and decay of the Top-K\n\n`TopK::info(string $key): TopKInfo`\n\nSee https://oss.redislabs.com/redisbloom/TopK_Commands/#topkinfo.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpalicao%2Fphprebloom","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpalicao%2Fphprebloom","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpalicao%2Fphprebloom/lists"}