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
c26127b5
Commit
c26127b5
authored
Mar 30, 2022
by
wangwei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加根据template作为参数写入布隆方法
parent
e1b35b0b
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
1 deletion
+26
-1
build.gradle
build.gradle
+1
-1
RedisBloomHandler.java
...duiba/spring/boot/starter/dsp/util/RedisBloomHandler.java
+25
-0
No files found.
build.gradle
View file @
c26127b5
...
...
@@ -38,7 +38,7 @@ allprojects {
}
group
=
"cn.com.duiba.boot"
version
=
"0.0.3
6
"
version
=
"0.0.3
7-SNAPSHOT
"
}
subprojects
{
...
...
spring-boot-starter-dsp-util/src/main/java/cn/com/duiba/spring/boot/starter/dsp/util/RedisBloomHandler.java
View file @
c26127b5
...
...
@@ -104,6 +104,24 @@ public class RedisBloomHandler<K, V> {
},
true
);
}
public
Boolean
addString
(
String
key
,
String
value
)
{
byte
[]
rawKey
=
rawString
(
key
);
byte
[]
rawValue
=
rawString
(
value
);
return
(
Boolean
)
redisTemplate
.
execute
(
connection
->
{
Long
l
=
(
Long
)
connection
.
execute
(
ADD
,
rawKey
,
rawValue
);
return
Objects
.
equals
(
l
,
1L
);
},
true
);
}
public
Boolean
addString
(
RedisTemplate
redisTemplate
,
String
key
,
String
value
)
{
byte
[]
rawKey
=
rawString
(
key
);
byte
[]
rawValue
=
rawString
(
value
);
return
(
Boolean
)
redisTemplate
.
execute
(
connection
->
{
Long
l
=
(
Long
)
connection
.
execute
(
ADD
,
rawKey
,
rawValue
);
return
Objects
.
equals
(
l
,
1L
);
},
true
);
}
public
Boolean
[]
addMulti
(
K
key
,
V
...
values
)
{
byte
[][]
rawArgs
=
rawArgs
(
key
,
values
);
return
(
Boolean
[])
redisTemplate
.
execute
(
connection
->
{
...
...
@@ -141,6 +159,13 @@ public class RedisBloomHandler<K, V> {
return
redisTemplate
.
hasKey
(
key
);
}
public
Boolean
hasBloom
(
RedisTemplate
redisTemplate
,
K
key
)
{
if
(
redisTemplate
==
null
)
{
redisTemplate
=
this
.
redisTemplate
;
}
return
redisTemplate
.
hasKey
(
key
);
}
byte
[]
rawKey
(
Object
key
)
{
Assert
.
notNull
(
key
,
"non null key required"
);
return
this
.
keySerializer
()
==
null
&&
key
instanceof
byte
[]
?
(
byte
[])
((
byte
[])
key
)
:
this
.
keySerializer
().
serialize
(
key
);
...
...
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