mu / bloomfilter
redsi布隆过滤器
1.0.0
2019-11-26 06:53 UTC
Requires
- ext-redis: *
This package is auto-updated.
Last update: 2025-03-10 17:00:44 UTC
README
redsi布隆过滤器.
Installing
$ composer require mu/bloomfilter -vvv
Usage
使用场景:
- 判断ip是否需要拦截
- 判断用户是否为会员
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:
- 胡超博客.
License
MIT