redis插件安装-bloom模块

布隆过滤器

Redis 官方提供的布隆过滤器到了 Redis 4.0 提供了插件功能之后才正式登场。布隆过滤
器作为一个插件加载到 Redis Server 中,给 Redis 提供了强大的布隆去重功能

特性

当布隆过滤器说某个值存在时,这个值可能不存在;当它说不存在时,那就肯定不存

如何安装

  • 模块文档:https://redis.io/modules
  • bloom模块:https://github.com/RedisBloom/RedisBloom
  • bloom模块release版本:https://github.com/RedisBloom/RedisBloom/releases

下载并编译

[root]# wget "https://github.com/RedisBloom/RedisBloom/archive/v2.2.0.tar.gz"
[root]# tar zxvf v2.2.0.tar.gz 
[root]# cd  RedisBloom-2.2.0/
[root]# make
[root]# ll
-rwxr-xr-x 1 root root 331600 Mar 16 20:15 redisbloom.so

加载

./redis-server  ./../redis.conf   --loadmodule /opt/cache/RedisBloom-2.2.0/redisbloom.so

使用

  • 自定义参数

127.0.0.1:6379> bf.reserve email 0.01 100
OK
  • 新增
127.0.0.1:6379> bf.add emai [email protected]
(integer) 1
127.0.0.1:6379> bf.add emai [email protected]
(integer) 1

127.0.0.1:6379> bf.add emai [email protected]
(integer) 0
  • 获取

127.0.0.1:6379> bf.exists emai [email protected]
(integer) 0

127.0.0.1:6379> bf.exists emai [email protected]
(integer) 1

你可能感兴趣的:(redis插件安装-bloom模块)