Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sparkinzy/redis-bloom-filter
redis布隆过滤器 php版
https://github.com/sparkinzy/redis-bloom-filter
Last synced: 9 days ago
JSON representation
redis布隆过滤器 php版
- Host: GitHub
- URL: https://github.com/sparkinzy/redis-bloom-filter
- Owner: Sparkinzy
- License: mit
- Created: 2019-11-26T06:44:35.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2020-01-10T05:49:06.000Z (almost 5 years ago)
- Last Synced: 2024-11-07T18:54:11.288Z (11 days ago)
- Language: PHP
- Size: 6.84 KB
- Stars: 6
- Watchers: 2
- Forks: 9
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
bloomfilter
redsi布隆过滤器.
## Installing
```shell
$ composer require mu/bloomfilter -vvv
```## Usage
使用场景:
- 判断ip是否需要拦截
- 判断用户是否为会员```php
use Mu\Bloomfilter\BloomFilter;# redis服务器
$redis_conf = [
'host' => '127.0.0.1',
'port' => 6379,
'auth' => 'beauty',
'timeout' => 1,
'database' =>0
];$bloomfilter = new BloomFilter($redis_conf);
# 设置评论的空间
$bloomfilter->set_bucket('black_ips');
# 添加一个ip
$ip = '127.0.0.1';
$add_rs = $bloomfilter->add($ip);
# 批量添加
$ips = ['192.168.0.1','192.168.0.2'];
$adds_rs = $bloomfilter->multi_add($ips);# 检查ip
$rs = $bloomfilter->exists($ip);# 批量检查ip
$multi_rs = $bloomfilter->multi_exists($ips);```
## Contributing
You can contribute in one of three ways:
1. [胡超博客](http://imhuchao.com/1271.html).
## License
MIT