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
e9628ed1
Commit
e9628ed1
authored
Jun 29, 2022
by
lizhiheng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:新增saveBloom的相关方法,用于查看这次是第几次请求
parent
f17bb6ac
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
2 deletions
+31
-2
build.gradle
build.gradle
+1
-1
RedisBloomHandler.java
...duiba/spring/boot/starter/dsp/util/RedisBloomHandler.java
+30
-1
No files found.
build.gradle
View file @
e9628ed1
...
@@ -38,7 +38,7 @@ allprojects {
...
@@ -38,7 +38,7 @@ allprojects {
}
}
group
=
"cn.com.duiba.boot"
group
=
"cn.com.duiba.boot"
version
=
"0.0.5
6
"
version
=
"0.0.5
7
"
}
}
subprojects
{
subprojects
{
...
...
spring-boot-starter-dsp-util/src/main/java/cn/com/duiba/spring/boot/starter/dsp/util/RedisBloomHandler.java
View file @
e9628ed1
...
@@ -243,6 +243,34 @@ public class RedisBloomHandler<K, V> {
...
@@ -243,6 +243,34 @@ public class RedisBloomHandler<K, V> {
return
null
;
return
null
;
}
}
/**
* 配合saveBloom一起使用
* 查看这是第几次请求
*
* @param key redis key
* @param value 值
* @param levelCount 过滤总层次
* @return
*/
public
Integer
checkBloomTimes
(
String
key
,
String
value
,
Integer
levelCount
)
{
String
luaText
=
"local a = "
+
(
levelCount
+
1
)
+
"\n"
+
"for i = 1,"
+
(
levelCount
)
+
1
+
",1 do\n"
+
" if(redis.call('BF.EXISTS', KEYS[1], (ARGV[1] .. '_' .. i)) == 0) then\n"
+
" a = i;\n"
+
" break;\n"
+
" end\n"
+
"end\n"
+
"return a;"
;
DefaultRedisScript
<
Long
>
redisScript
=
new
DefaultRedisScript
<>();
redisScript
.
setScriptSource
(
new
StaticScriptSource
(
luaText
));
redisScript
.
setResultType
(
Long
.
class
);
Object
execute
=
redisTemplate
.
execute
(
redisScript
,
Collections
.
singletonList
(
key
),
value
,
String
.
valueOf
(
levelCount
));
if
(
NumberUtils
.
isNumeric
(
execute
+
""
))
{
return
Integer
.
valueOf
(
execute
+
""
);
}
return
null
;
}
/**
/**
* 添加到bloom
* 添加到bloom
* 添加该方法是为了兼容lettuce客户端,lettuce会进行命令校验
* 添加该方法是为了兼容lettuce客户端,lettuce会进行命令校验
...
@@ -268,8 +296,9 @@ public class RedisBloomHandler<K, V> {
...
@@ -268,8 +296,9 @@ public class RedisBloomHandler<K, V> {
/**
/**
* 自助接口,传入需要使用到的redis实例、lua表达式、key和value
* 自助接口,传入需要使用到的redis实例、lua表达式、key和value
* 需要注意的是,这个方法返回类型是Object,需要下游强转,使用前请先先本地lua调试
* 需要注意的是,这个方法返回类型是Object,需要下游强转,使用前请先先本地lua调试
*
* @param redisTemplate 使用到到redis实例
* @param redisTemplate 使用到到redis实例
* @param luaText 传入到lua脚本
* @param luaText
传入到lua脚本
* @param key
* @param key
* @param value
* @param value
* @return
* @return
...
...
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