Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
midjourney-proxy
Overview
Overview
Details
Activity
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
徐少华
midjourney-proxy
Commits
6dd14a1a
Commit
6dd14a1a
authored
Apr 30, 2021
by
郑永强
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: [1004590] 广告平台系统
parent
23082ec7
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
0 deletions
+32
-0
JedisClusterUtils.java
...om/pcloud/common/utils/cache/redis/JedisClusterUtils.java
+32
-0
No files found.
pcloud-common/src/main/java/com/pcloud/common/utils/cache/redis/JedisClusterUtils.java
View file @
6dd14a1a
...
...
@@ -6,6 +6,7 @@ package com.pcloud.common.utils.cache.redis;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Optional
;
import
java.util.Set
;
import
org.apache.commons.lang3.StringUtils
;
...
...
@@ -152,6 +153,37 @@ public class JedisClusterUtils {
}
/**
* 保存一个字符串到redis中并指定过期时间
* nxxx: NX 不存在则添加
* expx: EX:秒;PX:毫秒;
*/
public
static
boolean
set
(
String
key
,
String
value
,
String
nxxx
,
String
expx
,
Integer
seconds
)
{
try
{
seconds
=
Optional
.
ofNullable
(
seconds
).
orElse
(
60
);
String
result
=
jedisCluster
.
set
(
key
,
value
,
nxxx
,
expx
,
seconds
);
return
"OK"
.
equalsIgnoreCase
(
result
);
}
catch
(
Exception
e
)
{
LOGGER
.
warn
(
"jedis缓存保存失败:"
+
e
.
getMessage
(),
e
);
return
false
;
}
}
/**
* 加锁
*/
public
static
boolean
lock
(
String
key
,
Integer
seconds
)
{
try
{
seconds
=
Optional
.
ofNullable
(
seconds
).
orElse
(
60
);
String
result
=
jedisCluster
.
set
(
key
,
String
.
valueOf
(
System
.
currentTimeMillis
()),
"NX"
,
"EX"
,
seconds
);
return
"OK"
.
equalsIgnoreCase
(
result
);
}
catch
(
Exception
e
)
{
LOGGER
.
warn
(
"jedis缓存保存失败:"
+
e
.
getMessage
(),
e
);
return
false
;
}
}
/**
* 保存一个字符串到redis中,长期有效
*
* @param objecKey 键
...
...
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