Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
spring-boot-starter-dsp
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
shenjiaqing
spring-boot-starter-dsp
Commits
c7299531
Commit
c7299531
authored
Jun 01, 2022
by
lizhiheng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:新增luaAdd方法,把BF.ADD命令通过lua的形式去执行
parent
a4d5a4f5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
1 deletion
+21
-1
build.gradle
build.gradle
+1
-1
RedisBloomHandler.java
...duiba/spring/boot/starter/dsp/util/RedisBloomHandler.java
+20
-0
No files found.
build.gradle
View file @
c7299531
...
...
@@ -38,7 +38,7 @@ allprojects {
}
group
=
"cn.com.duiba.boot"
version
=
"0.0.
49
"
version
=
"0.0.
50
"
}
subprojects
{
...
...
spring-boot-starter-dsp-util/src/main/java/cn/com/duiba/spring/boot/starter/dsp/util/RedisBloomHandler.java
View file @
c7299531
...
...
@@ -243,6 +243,26 @@ public class RedisBloomHandler<K, V> {
return
null
;
}
/**
* 添加到bloom
* 添加该方法是为了兼容lettuce客户端,lettuce会进行命令校验
* 其枚举值类:{CommandType}中没有BF.ADD或者BF.MEXISTS等方法,只能通过直接写在lua中,绕过命令校验
* @param key redis key
* @param value 值
* @return
*/
public
Integer
luaAdd
(
String
key
,
String
value
)
{
String
luaText
=
"if (redis.call('BF.ADD',KEYS[1],ARGV[1]))==1 then return 1 else return 0 end"
;
DefaultRedisScript
<
Long
>
redisScript
=
new
DefaultRedisScript
<>();
redisScript
.
setScriptSource
(
new
StaticScriptSource
(
luaText
));
redisScript
.
setResultType
(
Long
.
class
);
Object
execute
=
redisTemplate
.
execute
(
redisScript
,
Collections
.
singletonList
(
key
),
value
);
if
(
NumberUtils
.
isNumeric
(
execute
+
""
))
{
return
Integer
.
valueOf
(
execute
+
""
);
}
return
null
;
}
/**
* 判断创建redis 布隆过滤器
*
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment