记得上下班打卡 | git大法好,push需谨慎
Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
liquidnet-bus-v1
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
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
董敬伟
liquidnet-bus-v1
Commits
dc55598f
Commit
dc55598f
authored
Jul 21, 2022
by
胡佳晨
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改 redis配置
修改配置文件指向 新db mongo redis
parent
3ecc4311
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
211 additions
and
171 deletions
+211
-171
AbstractRedisConfig.java
...uidnet.common.cache/redis/config/AbstractRedisConfig.java
+26
-5
RedisConfig.java
.../com.liquidnet.common.cache/redis/config/RedisConfig.java
+1
-1
AbstractRedisUtil.java
....liquidnet.common.cache/redis/util/AbstractRedisUtil.java
+63
-95
RedisAdamUtil.java
.../com.liquidnet.common.cache/redis/util/RedisAdamUtil.java
+9
-1
RedisCandyUtil.java
...com.liquidnet.common.cache/redis/util/RedisCandyUtil.java
+9
-1
RedisDragonUtil.java
...om.liquidnet.common.cache/redis/util/RedisDragonUtil.java
+8
-2
RedisGalaxyUtil.java
...om.liquidnet.common.cache/redis/util/RedisGalaxyUtil.java
+9
-1
RedisGoblinUtil.java
...om.liquidnet.common.cache/redis/util/RedisGoblinUtil.java
+9
-2
RedisKylinUtil.java
...com.liquidnet.common.cache/redis/util/RedisKylinUtil.java
+8
-2
RedisSweetUtil.java
...com.liquidnet.common.cache/redis/util/RedisSweetUtil.java
+9
-1
application-dev.yml
liquidnet-bus-config/liquidnet-config/application-dev.yml
+41
-41
application-test.yml
liquidnet-bus-config/liquidnet-config/application-test.yml
+19
-19
No files found.
liquidnet-bus-common/liquidnet-common-cache/liquidnet-common-cache-redis/src/main/java/com.liquidnet.common.cache/redis/config/AbstractRedisConfig.java
View file @
dc55598f
...
...
@@ -39,6 +39,8 @@ public abstract class AbstractRedisConfig {
public
Map
<
Integer
,
RedisTemplate
<
String
,
Object
>>
redisTemplateMap
=
new
HashMap
<>();
private
StringRedisTemplate
stringRedisTemplate
=
new
StringRedisTemplate
();
abstract
String
getHost
();
abstract
int
getPort
();
abstract
String
getPassword
();
...
...
@@ -51,7 +53,7 @@ public abstract class AbstractRedisConfig {
@PostConstruct
public
void
initRedisTemp
()
throws
Exception
{
log
.
info
(
"############################################################"
);
log
.
info
(
"###### START 初始化 Redis
"
+
this
.
getClass
().
getSimpleName
()+
"连接池 START ######"
);
log
.
info
(
"###### START 初始化 Redis
{} "
+
this
.
getClass
().
getSimpleName
()+
"连接池 START ######"
,
this
.
getHost
()
);
if
(
StringUtils
.
isEmpty
(
getHost
())||
getHost
().
equalsIgnoreCase
(
"null"
)){
log
.
info
(
"无配置,不需要初始化!"
);
return
;
...
...
@@ -69,6 +71,21 @@ public abstract class AbstractRedisConfig {
redisTemplateMap
.
put
(
defaultDb
,
getRedisTemplate
(
defaultDb
));
}
log
.
info
(
"###### END 初始化 Redis 连接池 END ######"
);
log
.
info
(
"###### START 初始化 Redis-queue{} "
+
this
.
getClass
().
getSimpleName
()+
"连接池 START ######"
,
this
.
getHost
());
//初始化队列
LettuceConnectionFactory
factory
=
null
;
if
(
totalDbs
==
1
){
log
.
info
(
"###### 正在加载Redis-queue-db-"
+
defaultDb
+
" ######"
);
factory
=
getDbFactory
(
defaultDb
);
}
else
{
log
.
info
(
"###### 正在加载Redis-queue-db-"
+
(
totalDbs
-
1
)
+
" ######"
);
factory
=
getDbFactory
(
totalDbs
-
1
);
}
stringRedisTemplate
.
setConnectionFactory
(
factory
);
stringRedisTemplate
.
afterPropertiesSet
();
log
.
info
(
"###### END 初始化 Redis-queue 连接池 END ######"
);
}
private
RedisTemplate
<
String
,
Object
>
getRedisTemplate
(
int
dbNo
)
{
...
...
@@ -127,6 +144,10 @@ public abstract class AbstractRedisConfig {
// }
public
StringRedisTemplate
getStringRedisTemplate
(){
return
stringRedisTemplate
;
}
public
StringRedisTemplate
getDefaultStringRedisTemplate
(){
if
(
StringUtils
.
isEmpty
(
getHost
())||
getHost
().
equalsIgnoreCase
(
"null"
)){
log
.
info
(
"无配置,不需要初始化!"
);
return
null
;
...
...
@@ -137,10 +158,10 @@ public abstract class AbstractRedisConfig {
}
else
{
factory
=
getDbFactory
(
totalDbs
-
1
);
}
StringRedisTemplate
r
edisTemplate
=
new
StringRedisTemplate
();
r
edisTemplate
.
setConnectionFactory
(
factory
);
r
edisTemplate
.
afterPropertiesSet
();
return
r
edisTemplate
;
StringRedisTemplate
stringR
edisTemplate
=
new
StringRedisTemplate
();
stringR
edisTemplate
.
setConnectionFactory
(
factory
);
stringR
edisTemplate
.
afterPropertiesSet
();
return
stringR
edisTemplate
;
}
private
void
setSerializer
(
RedisTemplate
<
String
,
Object
>
template
)
{
...
...
liquidnet-bus-common/liquidnet-common-cache/liquidnet-common-cache-redis/src/main/java/com.liquidnet.common.cache/redis/config/RedisConfig.java
View file @
dc55598f
...
...
@@ -42,7 +42,7 @@ public class RedisConfig extends AbstractRedisConfig{
@Bean
public
StringRedisTemplate
stringRedisTemplate
()
{
return
this
.
getStringRedisTemplate
();
return
this
.
get
Default
StringRedisTemplate
();
}
String
getHost
(){
...
...
liquidnet-bus-common/liquidnet-common-cache/liquidnet-common-cache-redis/src/main/java/com.liquidnet.common.cache/redis/util/AbstractRedisUtil.java
View file @
dc55598f
...
...
@@ -18,6 +18,11 @@ import java.util.concurrent.TimeUnit;
* @date 2020/8/26 13:11
*/
public
abstract
class
AbstractRedisUtil
{
/**
* 补全KEY前缀
*/
public
abstract
String
fillingKey
(
String
key
);
/**
* 获取redis初始化信息
*/
...
...
@@ -46,17 +51,13 @@ public abstract class AbstractRedisUtil {
* @param time 时间(秒)
* @return
*/
public
boolean
expire
(
String
key
,
long
time
)
{
private
boolean
expire
(
String
key
,
long
time
)
{
if
(
time
>
0
)
{
this
.
getRedisConfig
().
getRedisTemplateByDb
(
this
.
getIndex
(
key
)).
expire
(
key
,
time
,
TimeUnit
.
SECONDS
);
}
return
true
;
}
...
...
@@ -66,11 +67,10 @@ public abstract class AbstractRedisUtil {
* @param key 键 不能为null
* @return 时间(秒) 返回0代表为永久有效
*/
public
long
getExpire
(
String
key
)
{
key
=
this
.
fillingKey
(
key
);
return
this
.
getRedisConfig
().
getRedisTemplateByDb
(
this
.
getIndex
(
key
)).
getExpire
(
key
,
TimeUnit
.
SECONDS
);
}
...
...
@@ -80,11 +80,10 @@ public abstract class AbstractRedisUtil {
* @param key 键
* @return true 存在 false不存在
*/
public
boolean
hasKey
(
String
key
)
{
key
=
this
.
fillingKey
(
key
);
return
this
.
getRedisConfig
().
getRedisTemplateByDb
(
this
.
getIndex
(
key
)).
hasKey
(
key
);
}
/**
...
...
@@ -93,6 +92,8 @@ public abstract class AbstractRedisUtil {
* @param prefix Key前缀
*/
public
void
delKeysByPrefix
(
String
prefix
)
{
prefix
=
this
.
fillingKey
(
prefix
);
if
(
null
!=
prefix
&&
prefix
.
trim
().
length
()
>
0
)
{
for
(
Integer
key
:
this
.
getRedisConfig
().
redisTemplateMap
.
keySet
())
{
Set
<
String
>
keys
=
this
.
getRedisConfig
().
getRedisTemplateByDb
(
key
).
keys
(
prefix
.
concat
(
"*"
));
...
...
@@ -104,27 +105,25 @@ public abstract class AbstractRedisUtil {
}
}
/**
* 删除缓存(多db情况需要单独实现批量删除-该方法慎重使用)
*
* @param key 可以传一个值 或多个
*/
@SuppressWarnings
(
"unchecked"
)
public
void
del
(
String
...
key
)
{
if
(
key
!=
null
&&
key
.
length
>
0
)
{
if
(
key
.
length
==
1
)
{
String
keyStr
=
this
.
fillingKey
(
key
[
0
]);
this
.
getRedisConfig
().
getRedisTemplateByDb
(
this
.
getIndex
(
key
[
0
])).
delete
(
key
[
0
]);
this
.
getRedisConfig
().
getRedisTemplateByDb
(
this
.
getIndex
(
keyStr
)).
delete
(
keyStr
);
}
else
{
// redisTemplate.delete(CollectionUtils.arrayToList(key));
for
(
String
keyStr
:
key
)
{
keyStr
=
this
.
fillingKey
(
keyStr
);
this
.
getRedisConfig
().
getRedisTemplateByDb
(
this
.
getIndex
(
keyStr
)).
delete
(
keyStr
);
}
}
...
...
@@ -150,6 +149,7 @@ public abstract class AbstractRedisUtil {
hashMap
=
hashMapIntegerArrayList
();
//构建 需要删除的Redis HashMapDBKey
for
(
String
keyStr
:
key
)
{
keyStr
=
this
.
fillingKey
(
keyStr
);
Integer
dbPosition
=
this
.
getIndex
(
keyStr
);
ArrayList
<
String
>
dbArray
;
if
(
hashMap
.
containsKey
(
dbPosition
))
{
...
...
@@ -179,9 +179,13 @@ public abstract class AbstractRedisUtil {
*/
public
Object
get
(
String
key
)
{
if
(
null
==
key
)
{
return
null
;
}
return
key
==
null
?
null
:
this
.
getRedisConfig
().
getRedisTemplateByDb
(
this
.
getIndex
(
key
)).
opsForValue
().
get
(
key
);
key
=
this
.
fillingKey
(
key
);
return
this
.
getRedisConfig
().
getRedisTemplateByDb
(
this
.
getIndex
(
key
)).
opsForValue
().
get
(
key
);
}
...
...
@@ -194,13 +198,11 @@ public abstract class AbstractRedisUtil {
*/
public
boolean
set
(
String
key
,
Object
value
)
{
key
=
this
.
fillingKey
(
key
);
this
.
getRedisConfig
().
getRedisTemplateByDb
(
this
.
getIndex
(
key
)).
opsForValue
().
set
(
key
,
value
);
return
true
;
}
...
...
@@ -215,11 +217,10 @@ public abstract class AbstractRedisUtil {
public
boolean
set
(
String
key
,
Object
value
,
long
time
)
{
if
(
time
>
0
)
{
key
=
this
.
fillingKey
(
key
);
RedisTemplate
<
String
,
Object
>
redisTemplate
=
this
.
getRedisConfig
().
getRedisTemplateByDb
(
this
.
getIndex
(
key
));
redisTemplate
.
opsForValue
().
set
(
key
,
value
,
time
,
TimeUnit
.
SECONDS
);
}
else
{
set
(
key
,
value
);
...
...
@@ -227,11 +228,8 @@ public abstract class AbstractRedisUtil {
}
return
true
;
}
/**
* 递增
*
...
...
@@ -239,7 +237,6 @@ public abstract class AbstractRedisUtil {
* @param delta 要增加几(大于0)
* @return
*/
public
long
incr
(
String
key
,
long
delta
)
{
if
(
delta
<
0
)
{
...
...
@@ -248,8 +245,9 @@ public abstract class AbstractRedisUtil {
}
return
this
.
getRedisConfig
().
getRedisTemplateByDb
(
this
.
getIndex
(
key
)).
opsForValue
().
increment
(
key
,
delta
);
key
=
this
.
fillingKey
(
key
);
return
this
.
getRedisConfig
().
getRedisTemplateByDb
(
this
.
getIndex
(
key
)).
opsForValue
().
increment
(
key
,
delta
);
}
...
...
@@ -269,8 +267,9 @@ public abstract class AbstractRedisUtil {
}
return
this
.
getRedisConfig
().
getRedisTemplateByDb
(
this
.
getIndex
(
key
)).
opsForValue
().
increment
(
key
,
-
delta
);
key
=
this
.
fillingKey
(
key
);
return
this
.
getRedisConfig
().
getRedisTemplateByDb
(
this
.
getIndex
(
key
)).
opsForValue
().
increment
(
key
,
-
delta
);
}
...
...
@@ -283,12 +282,15 @@ public abstract class AbstractRedisUtil {
* @param item 项 不能为null
* @return 值
*/
public
Object
hget
(
String
key
,
String
item
)
{
key
=
this
.
fillingKey
(
key
);
return
this
.
getRedisConfig
().
getRedisTemplateByDb
(
this
.
getIndex
(
key
)).
opsForHash
().
get
(
key
,
item
);
}
public
Object
hkeys
(
String
key
)
{
key
=
this
.
fillingKey
(
key
);
return
this
.
getRedisConfig
().
getRedisTemplateByDb
(
this
.
getIndex
(
key
)).
opsForHash
().
keys
(
key
);
}
...
...
@@ -301,9 +303,9 @@ public abstract class AbstractRedisUtil {
*/
public
Map
<
Object
,
Object
>
hmget
(
String
key
)
{
key
=
this
.
fillingKey
(
key
);
return
this
.
getRedisConfig
().
getRedisTemplateByDb
(
this
.
getIndex
(
key
)).
opsForHash
().
entries
(
key
);
}
...
...
@@ -316,13 +318,11 @@ public abstract class AbstractRedisUtil {
*/
public
boolean
hmset
(
String
key
,
Map
<
String
,
Object
>
map
)
{
key
=
this
.
fillingKey
(
key
);
this
.
getRedisConfig
().
getRedisTemplateByDb
(
this
.
getIndex
(
key
)).
opsForHash
().
putAll
(
key
,
map
);
return
true
;
}
...
...
@@ -336,7 +336,7 @@ public abstract class AbstractRedisUtil {
*/
public
boolean
hmset
(
String
key
,
Map
<
String
,
Object
>
map
,
long
time
)
{
key
=
this
.
fillingKey
(
key
);
this
.
getRedisConfig
().
getRedisTemplateByDb
(
this
.
getIndex
(
key
)).
opsForHash
().
putAll
(
key
,
map
);
...
...
@@ -345,10 +345,7 @@ public abstract class AbstractRedisUtil {
expire
(
key
,
time
);
}
return
true
;
}
...
...
@@ -362,13 +359,11 @@ public abstract class AbstractRedisUtil {
*/
public
boolean
hset
(
String
key
,
String
item
,
Object
value
)
{
key
=
this
.
fillingKey
(
key
);
this
.
getRedisConfig
().
getRedisTemplateByDb
(
this
.
getIndex
(
key
)).
opsForHash
().
put
(
key
,
item
,
value
);
return
true
;
}
...
...
@@ -383,7 +378,7 @@ public abstract class AbstractRedisUtil {
*/
public
boolean
hset
(
String
key
,
String
item
,
Object
value
,
long
time
)
{
key
=
this
.
fillingKey
(
key
);
this
.
getRedisConfig
().
getRedisTemplateByDb
(
this
.
getIndex
(
key
)).
opsForHash
().
put
(
key
,
item
,
value
);
...
...
@@ -394,8 +389,6 @@ public abstract class AbstractRedisUtil {
}
return
true
;
}
...
...
@@ -407,9 +400,9 @@ public abstract class AbstractRedisUtil {
*/
public
void
hdel
(
String
key
,
Object
...
item
)
{
key
=
this
.
fillingKey
(
key
);
this
.
getRedisConfig
().
getRedisTemplateByDb
(
this
.
getIndex
(
key
)).
opsForHash
().
delete
(
key
,
item
);
}
...
...
@@ -422,9 +415,9 @@ public abstract class AbstractRedisUtil {
*/
public
boolean
hHasKey
(
String
key
,
String
item
)
{
key
=
this
.
fillingKey
(
key
);
return
this
.
getRedisConfig
().
getRedisTemplateByDb
(
this
.
getIndex
(
key
)).
opsForHash
().
hasKey
(
key
,
item
);
}
...
...
@@ -438,9 +431,9 @@ public abstract class AbstractRedisUtil {
*/
public
double
hincr
(
String
key
,
String
item
,
double
by
)
{
key
=
this
.
fillingKey
(
key
);
return
this
.
getRedisConfig
().
getRedisTemplateByDb
(
this
.
getIndex
(
key
)).
opsForHash
().
increment
(
key
,
item
,
by
);
}
...
...
@@ -454,9 +447,9 @@ public abstract class AbstractRedisUtil {
*/
public
double
hdecr
(
String
key
,
String
item
,
double
by
)
{
key
=
this
.
fillingKey
(
key
);
return
this
.
getRedisConfig
().
getRedisTemplateByDb
(
this
.
getIndex
(
key
)).
opsForHash
().
increment
(
key
,
item
,
-
by
);
}
...
...
@@ -470,11 +463,9 @@ public abstract class AbstractRedisUtil {
*/
public
Set
<
Object
>
sGet
(
String
key
)
{
key
=
this
.
fillingKey
(
key
);
return
this
.
getRedisConfig
().
getRedisTemplateByDb
(
this
.
getIndex
(
key
)).
opsForSet
().
members
(
key
);
}
...
...
@@ -487,11 +478,9 @@ public abstract class AbstractRedisUtil {
*/
public
boolean
sHasKey
(
String
key
,
Object
value
)
{
key
=
this
.
fillingKey
(
key
);
return
this
.
getRedisConfig
().
getRedisTemplateByDb
(
this
.
getIndex
(
key
)).
opsForSet
().
isMember
(
key
,
value
);
}
...
...
@@ -504,11 +493,9 @@ public abstract class AbstractRedisUtil {
*/
public
long
sSet
(
String
key
,
Object
...
values
)
{
key
=
this
.
fillingKey
(
key
);
return
this
.
getRedisConfig
().
getRedisTemplateByDb
(
this
.
getIndex
(
key
)).
opsForSet
().
add
(
key
,
values
);
}
...
...
@@ -522,7 +509,7 @@ public abstract class AbstractRedisUtil {
*/
public
long
sSetAndTime
(
String
key
,
long
time
,
Object
...
values
)
{
key
=
this
.
fillingKey
(
key
);
Long
count
=
this
.
getRedisConfig
().
getRedisTemplateByDb
(
this
.
getIndex
(
key
)).
opsForSet
().
add
(
key
,
values
);
...
...
@@ -531,8 +518,6 @@ public abstract class AbstractRedisUtil {
expire
(
key
,
time
);
return
count
;
}
...
...
@@ -542,13 +527,10 @@ public abstract class AbstractRedisUtil {
* @param key 键
* @return
*/
public
long
sGetSetSize
(
String
key
)
{
key
=
this
.
fillingKey
(
key
);
return
this
.
getRedisConfig
().
getRedisTemplateByDb
(
this
.
getIndex
(
key
)).
opsForSet
().
size
(
key
);
}
...
...
@@ -559,15 +541,12 @@ public abstract class AbstractRedisUtil {
* @param values 值 可以是多个
* @return 移除的个数
*/
public
long
setRemove
(
String
key
,
Object
...
values
)
{
key
=
this
.
fillingKey
(
key
);
Long
count
=
this
.
getRedisConfig
().
getRedisTemplateByDb
(
this
.
getIndex
(
key
)).
opsForSet
().
remove
(
key
,
values
);
return
count
;
}
// ===============================list=================================
...
...
@@ -583,11 +562,9 @@ public abstract class AbstractRedisUtil {
*/
public
List
<
Object
>
lGet
(
String
key
,
long
start
,
long
end
)
{
key
=
this
.
fillingKey
(
key
);
return
this
.
getRedisConfig
().
getRedisTemplateByDb
(
this
.
getIndex
(
key
)).
opsForList
().
range
(
key
,
start
,
end
);
}
...
...
@@ -599,11 +576,9 @@ public abstract class AbstractRedisUtil {
*/
public
long
lGetListSize
(
String
key
)
{
key
=
this
.
fillingKey
(
key
);
return
this
.
getRedisConfig
().
getRedisTemplateByDb
(
this
.
getIndex
(
key
)).
opsForList
().
size
(
key
);
}
...
...
@@ -616,11 +591,9 @@ public abstract class AbstractRedisUtil {
*/
public
Object
lGetIndex
(
String
key
,
long
index
)
{
key
=
this
.
fillingKey
(
key
);
return
this
.
getRedisConfig
().
getRedisTemplateByDb
(
this
.
getIndex
(
key
)).
opsForList
().
index
(
key
,
index
);
}
...
...
@@ -632,13 +605,11 @@ public abstract class AbstractRedisUtil {
* @return
*/
public
boolean
lSet
(
String
key
,
Object
value
)
{
key
=
this
.
fillingKey
(
key
);
this
.
getRedisConfig
().
getRedisTemplateByDb
(
this
.
getIndex
(
key
)).
opsForList
().
rightPush
(
key
,
value
);
return
true
;
}
...
...
@@ -652,7 +623,7 @@ public abstract class AbstractRedisUtil {
*/
public
boolean
lSet
(
String
key
,
Object
value
,
long
time
)
{
key
=
this
.
fillingKey
(
key
);
this
.
getRedisConfig
().
getRedisTemplateByDb
(
this
.
getIndex
(
key
)).
opsForList
().
rightPush
(
key
,
value
);
...
...
@@ -661,8 +632,6 @@ public abstract class AbstractRedisUtil {
expire
(
key
,
time
);
return
true
;
}
...
...
@@ -674,13 +643,11 @@ public abstract class AbstractRedisUtil {
* @return
*/
public
boolean
lSet
(
String
key
,
List
<
Object
>
value
)
{
key
=
this
.
fillingKey
(
key
);
this
.
getRedisConfig
().
getRedisTemplateByDb
(
this
.
getIndex
(
key
)).
opsForList
().
rightPushAll
(
key
,
value
);
return
true
;
}
...
...
@@ -694,7 +661,7 @@ public abstract class AbstractRedisUtil {
*/
public
boolean
lSet
(
String
key
,
List
<
Object
>
value
,
long
time
)
{
key
=
this
.
fillingKey
(
key
);
this
.
getRedisConfig
().
getRedisTemplateByDb
(
this
.
getIndex
(
key
)).
opsForList
().
rightPushAll
(
key
,
value
);
...
...
@@ -703,8 +670,6 @@ public abstract class AbstractRedisUtil {
expire
(
key
,
time
);
return
true
;
}
...
...
@@ -718,13 +683,11 @@ public abstract class AbstractRedisUtil {
*/
public
boolean
lUpdateIndex
(
String
key
,
long
index
,
Object
value
)
{
key
=
this
.
fillingKey
(
key
);
this
.
getRedisConfig
().
getRedisTemplateByDb
(
this
.
getIndex
(
key
)).
opsForList
().
set
(
key
,
index
,
value
);
return
true
;
}
...
...
@@ -736,15 +699,12 @@ public abstract class AbstractRedisUtil {
* @param value 值
* @return 移除的个数
*/
public
long
lRemove
(
String
key
,
long
count
,
Object
value
)
{
key
=
this
.
fillingKey
(
key
);
Long
remove
=
this
.
getRedisConfig
().
getRedisTemplateByDb
(
this
.
getIndex
(
key
)).
opsForList
().
remove
(
key
,
count
,
value
);
return
remove
;
}
public
RedisTemplate
<
String
,
Object
>
getRedisTemplateByDb
(
int
db
)
{
...
...
@@ -753,15 +713,20 @@ public abstract class AbstractRedisUtil {
public
Object
getDB15RedisHGet
(
String
redisKey
,
String
item
)
{
redisKey
=
this
.
fillingKey
(
redisKey
);
return
this
.
getRedisConfig
().
getRedisTemplateByDb
(
15
).
opsForHash
().
get
(
redisKey
,
item
);
}
public
Object
getDB15RedisGet
(
String
redisKey
)
{
redisKey
=
this
.
fillingKey
(
redisKey
);
return
this
.
getRedisConfig
().
getRedisTemplateByDb
(
15
).
opsForValue
().
get
(
redisKey
);
}
public
boolean
getDB15RedisHasKey
(
String
redisKey
,
String
item
)
{
redisKey
=
this
.
fillingKey
(
redisKey
);
return
this
.
getRedisConfig
().
getRedisTemplateByDb
(
15
).
opsForSet
().
isMember
(
redisKey
,
item
);
}
...
...
@@ -773,6 +738,8 @@ public abstract class AbstractRedisUtil {
* @return
*/
public
boolean
lock
(
String
key
,
int
value
,
long
releaseTime
)
{
key
=
this
.
fillingKey
(
key
);
// 尝试获取锁
RedisTemplate
<
String
,
Object
>
redisTemplate
=
this
.
getRedisConfig
().
getRedisTemplateByDb
(
this
.
getIndex
(
key
));
Boolean
boo
=
redisTemplate
.
opsForValue
().
setIfAbsent
(
key
,
value
,
releaseTime
,
TimeUnit
.
SECONDS
);
...
...
@@ -785,6 +752,7 @@ public abstract class AbstractRedisUtil {
** @param key
*/
public
void
uLock
(
String
key
)
{
key
=
this
.
fillingKey
(
key
);
// 删除key即可释放锁
this
.
getRedisConfig
().
getRedisTemplateByDb
(
this
.
getIndex
(
key
)).
delete
(
key
);
}
...
...
liquidnet-bus-common/liquidnet-common-cache/liquidnet-common-cache-redis/src/main/java/com.liquidnet.common.cache/redis/util/RedisAdamUtil.java
View file @
dc55598f
...
...
@@ -4,6 +4,7 @@ import com.liquidnet.common.cache.redis.config.AbstractRedisConfig;
import
com.liquidnet.common.cache.redis.config.RedisAdamConfig
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Component
;
/**
...
...
@@ -20,10 +21,17 @@ import org.springframework.stereotype.Component;
public
final
class
RedisAdamUtil
extends
AbstractRedisUtil
{
@Autowired
private
RedisAdamConfig
redisConfig
;
@Value
(
"${spring.profiles.active:prod}"
)
private
String
prefix
;
@Override
public
String
fillingKey
(
String
key
)
{
return
prefix
.
equals
(
"prod"
)
?
key
:
prefix
.
concat
(
":"
).
concat
(
key
);
}
@Override
public
int
getDbs
()
{
log
.
info
(
"redisAdamUtil.totalDbs
==="
,
redisConfig
.
totalDbs
);
log
.
info
(
"redisAdamUtil.totalDbs
:{},prefix:{}==="
,
redisConfig
.
totalDbs
,
prefix
);
return
redisConfig
.
totalDbs
;
}
...
...
liquidnet-bus-common/liquidnet-common-cache/liquidnet-common-cache-redis/src/main/java/com.liquidnet.common.cache/redis/util/RedisCandyUtil.java
View file @
dc55598f
...
...
@@ -4,6 +4,7 @@ import com.liquidnet.common.cache.redis.config.AbstractRedisConfig;
import
com.liquidnet.common.cache.redis.config.RedisCandyConfig
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Component
;
/**
...
...
@@ -19,10 +20,17 @@ import org.springframework.stereotype.Component;
public
final
class
RedisCandyUtil
extends
AbstractRedisUtil
{
@Autowired
private
RedisCandyConfig
redisConfig
;
@Value
(
"${spring.profiles.active:prod}"
)
private
String
prefix
;
@Override
public
String
fillingKey
(
String
key
)
{
return
prefix
.
equals
(
"prod"
)
?
key
:
prefix
.
concat
(
":"
).
concat
(
key
);
}
@Override
public
int
getDbs
()
{
log
.
info
(
"redisCandyUtil.totalDbs
==="
,
redisConfig
.
totalDbs
);
log
.
info
(
"redisCandyUtil.totalDbs
:{},prefix:{}==="
,
redisConfig
.
totalDbs
,
prefix
);
return
redisConfig
.
totalDbs
;
}
...
...
liquidnet-bus-common/liquidnet-common-cache/liquidnet-common-cache-redis/src/main/java/com.liquidnet.common.cache/redis/util/RedisDragonUtil.java
View file @
dc55598f
...
...
@@ -4,6 +4,7 @@ import com.liquidnet.common.cache.redis.config.AbstractRedisConfig;
import
com.liquidnet.common.cache.redis.config.RedisDragonConfig
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Component
;
/**
...
...
@@ -20,15 +21,20 @@ import org.springframework.stereotype.Component;
public
final
class
RedisDragonUtil
extends
AbstractRedisUtil
{
@Autowired
private
RedisDragonConfig
redisConfig
;
@Value
(
"${spring.profiles.active:prod}"
)
private
String
prefix
;
@Override
public
String
fillingKey
(
String
key
)
{
return
prefix
.
equals
(
"prod"
)
?
key
:
prefix
.
concat
(
":"
).
concat
(
key
);
}
@Override
public
int
getDbs
()
{
log
.
info
(
"redisDragonUtil.totalDbs
==="
,
redisConfig
.
totalDbs
);
log
.
info
(
"redisDragonUtil.totalDbs
:{},prefix:{}==="
,
redisConfig
.
totalDbs
,
prefix
);
return
redisConfig
.
totalDbs
;
}
@Override
AbstractRedisConfig
getRedisConfig
()
{
return
this
.
redisConfig
;
...
...
liquidnet-bus-common/liquidnet-common-cache/liquidnet-common-cache-redis/src/main/java/com.liquidnet.common.cache/redis/util/RedisGalaxyUtil.java
View file @
dc55598f
...
...
@@ -4,6 +4,7 @@ import com.liquidnet.common.cache.redis.config.AbstractRedisConfig;
import
com.liquidnet.common.cache.redis.config.RedisGalaxyConfig
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Component
;
/**
...
...
@@ -20,10 +21,17 @@ import org.springframework.stereotype.Component;
public
final
class
RedisGalaxyUtil
extends
AbstractRedisUtil
{
@Autowired
private
RedisGalaxyConfig
redisConfig
;
@Value
(
"${spring.profiles.active:prod}"
)
private
String
prefix
;
@Override
public
String
fillingKey
(
String
key
)
{
return
prefix
.
equals
(
"prod"
)
?
key
:
prefix
.
concat
(
":"
).
concat
(
key
);
}
@Override
public
int
getDbs
()
{
log
.
info
(
"RedisGalaxyUtil.totalDbs
==="
,
redisConfig
.
totalDbs
);
log
.
info
(
"RedisGalaxyUtil.totalDbs
:{},prefix:{}==="
,
redisConfig
.
totalDbs
,
prefix
);
return
redisConfig
.
totalDbs
;
}
...
...
liquidnet-bus-common/liquidnet-common-cache/liquidnet-common-cache-redis/src/main/java/com.liquidnet.common.cache/redis/util/RedisGoblinUtil.java
View file @
dc55598f
package
com
.
liquidnet
.
common
.
cache
.
redis
.
util
;
import
com.liquidnet.common.cache.redis.config.AbstractRedisConfig
;
import
com.liquidnet.common.cache.redis.config.RedisAdamConfig
;
import
com.liquidnet.common.cache.redis.config.RedisGoblinConfig
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Component
;
/**
...
...
@@ -21,10 +21,17 @@ import org.springframework.stereotype.Component;
public
final
class
RedisGoblinUtil
extends
AbstractRedisUtil
{
@Autowired
private
RedisGoblinConfig
redisConfig
;
@Value
(
"${spring.profiles.active:prod}"
)
private
String
prefix
;
@Override
public
String
fillingKey
(
String
key
)
{
return
prefix
.
equals
(
"prod"
)
?
key
:
prefix
.
concat
(
":"
).
concat
(
key
);
}
@Override
public
int
getDbs
()
{
log
.
info
(
"redisAdamUtil.totalDbs
==="
,
redisConfig
.
totalDbs
);
log
.
info
(
"redisAdamUtil.totalDbs
:{},prefix:{}==="
,
redisConfig
.
totalDbs
,
prefix
);
return
redisConfig
.
totalDbs
;
}
...
...
liquidnet-bus-common/liquidnet-common-cache/liquidnet-common-cache-redis/src/main/java/com.liquidnet.common.cache/redis/util/RedisKylinUtil.java
View file @
dc55598f
...
...
@@ -4,6 +4,7 @@ import com.liquidnet.common.cache.redis.config.AbstractRedisConfig;
import
com.liquidnet.common.cache.redis.config.RedisKylinConfig
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Component
;
/**
...
...
@@ -20,15 +21,20 @@ import org.springframework.stereotype.Component;
public
final
class
RedisKylinUtil
extends
AbstractRedisUtil
{
@Autowired
private
RedisKylinConfig
redisConfig
;
@Value
(
"${spring.profiles.active:prod}"
)
private
String
prefix
;
@Override
public
String
fillingKey
(
String
key
)
{
return
prefix
.
equals
(
"prod"
)
?
key
:
prefix
.
concat
(
":"
).
concat
(
key
);
}
@Override
public
int
getDbs
()
{
log
.
info
(
"redisKylinUtil.totalDbs
==="
,
redisConfig
.
totalDbs
);
log
.
info
(
"redisKylinUtil.totalDbs
:{},prefix:{}==="
,
redisConfig
.
totalDbs
,
prefix
);
return
redisConfig
.
totalDbs
;
}
@Override
AbstractRedisConfig
getRedisConfig
()
{
return
this
.
redisConfig
;
...
...
liquidnet-bus-common/liquidnet-common-cache/liquidnet-common-cache-redis/src/main/java/com.liquidnet.common.cache/redis/util/RedisSweetUtil.java
View file @
dc55598f
...
...
@@ -4,6 +4,7 @@ import com.liquidnet.common.cache.redis.config.AbstractRedisConfig;
import
com.liquidnet.common.cache.redis.config.RedisSweetConfig
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Component
;
/**
...
...
@@ -20,10 +21,17 @@ import org.springframework.stereotype.Component;
public
final
class
RedisSweetUtil
extends
AbstractRedisUtil
{
@Autowired
private
RedisSweetConfig
redisConfig
;
@Value
(
"${spring.profiles.active:prod}"
)
private
String
prefix
;
@Override
public
String
fillingKey
(
String
key
)
{
return
prefix
.
equals
(
"prod"
)
?
key
:
prefix
.
concat
(
":"
).
concat
(
key
);
}
@Override
public
int
getDbs
()
{
log
.
info
(
"redisSweetUtil.totalDbs
==="
,
redisConfig
.
totalDbs
);
log
.
info
(
"redisSweetUtil.totalDbs
:{},prefix:{}==="
,
redisConfig
.
totalDbs
,
prefix
);
return
redisConfig
.
totalDbs
;
}
...
...
liquidnet-bus-config/liquidnet-config/application-dev.yml
View file @
dc55598f
...
...
@@ -13,8 +13,8 @@ liquidnet:
refresh-ttl
:
525600
blacklist_grace_period
:
5
mysql
:
urlHostAndPort
:
39.107.71.112:3308
username
:
root
urlHostAndPort
:
java-test.mysql.polardb.rds.aliyuncs.com:3306
username
:
zhengzai
password
:
Zhengzai@rd2U#
# rabbitmq:
# host: rabbitmq.zhengzai.tv
...
...
@@ -32,52 +32,52 @@ liquidnet:
disable
:
false
redis
:
kylin
:
d
bs
:
0,16
d
atabase
:
15
host
:
39.107.71.112
port
:
63
79
password
:
3Xa%8p
d
atabase
:
255
d
bs
:
0,256
host
:
r-2zeucai3yj2t0f4nmzpd.redis.rds.aliyuncs.com
port
:
63
80
password
:
7eoK2XehKqF1
goblin
:
d
bs
:
0,16
d
atabase
:
15
host
:
39.107.71.112
port
:
63
79
password
:
3Xa%8p
d
atabase
:
255
d
bs
:
0,256
host
:
r-2zeucai3yj2t0f4nmzpd.redis.rds.aliyuncs.com
port
:
63
80
password
:
7eoK2XehKqF1
slime
:
d
bs
:
0,16
d
atabase
:
15
host
:
39.107.71.112
port
:
63
79
password
:
3Xa%8p
d
atabase
:
255
d
bs
:
0,256
host
:
r-2zeucai3yj2t0f4nmzpd.redis.rds.aliyuncs.com
port
:
63
80
password
:
7eoK2XehKqF1
dragon
:
d
bs
:
0,16
d
atabase
:
15
host
:
39.107.71.112
port
:
63
79
password
:
3Xa%8p
d
atabase
:
255
d
bs
:
0,256
host
:
r-2zeucai3yj2t0f4nmzpd.redis.rds.aliyuncs.com
port
:
63
80
password
:
7eoK2XehKqF1
sweet
:
d
bs
:
0,16
d
atabase
:
15
host
:
39.107.71.112
port
:
63
79
password
:
3Xa%8p
d
atabase
:
255
d
bs
:
0,256
host
:
r-2zeucai3yj2t0f4nmzpd.redis.rds.aliyuncs.com
port
:
63
80
password
:
7eoK2XehKqF1
adam
:
d
bs
:
0,16
d
atabase
:
15
host
:
39.107.71.112
port
:
63
79
password
:
3Xa%8p
d
atabase
:
255
d
bs
:
0,256
host
:
r-2zeucai3yj2t0f4nmzpd.redis.rds.aliyuncs.com
port
:
63
80
password
:
7eoK2XehKqF1
candy
:
d
bs
:
0,16
d
atabase
:
15
host
:
39.107.71.112
port
:
63
79
password
:
3Xa%8p
d
atabase
:
255
d
bs
:
0,256
host
:
r-2zeucai3yj2t0f4nmzpd.redis.rds.aliyuncs.com
port
:
63
80
password
:
7eoK2XehKqF1
mongodb
:
host
:
39.107.71.112:270
17
port
:
270
17
user
:
admin
pwd
:
S
&y$
6d*JwJ
host
:
dds-2ze23697d93111041932-pub.mongodb.rds.aliyuncs.com:3717,dds-2ze23697d93111042720-pub.mongodb.rds.aliyuncs.com:37
17
port
:
37
17
user
:
root
pwd
:
S
y
6d*JwJ
service
:
adam
:
url-pay
:
...
...
liquidnet-bus-config/liquidnet-config/application-test.yml
View file @
dc55598f
...
...
@@ -32,52 +32,52 @@ liquidnet:
disable
:
false
redis
:
kylin
:
database
:
25
5
database
:
25
1
dbs
:
0,256
host
:
r-2zeucai3yj2t0f4nmz.redis.rds.aliyuncs.com
host
:
r-2zeucai3yj2t0f4nmz
pd
.redis.rds.aliyuncs.com
port
:
6380
password
:
7eoK2XehKqF1
goblin
:
database
:
25
5
database
:
25
1
dbs
:
0,256
host
:
r-2zeucai3yj2t0f4nmz.redis.rds.aliyuncs.com
host
:
r-2zeucai3yj2t0f4nmz
pd
.redis.rds.aliyuncs.com
port
:
6380
password
:
7eoK2XehKqF1
slime
:
database
:
25
5
database
:
25
1
dbs
:
0,256
host
:
r-2zeucai3yj2t0f4nmz.redis.rds.aliyuncs.com
host
:
r-2zeucai3yj2t0f4nmz
pd
.redis.rds.aliyuncs.com
port
:
6380
password
:
7eoK2XehKqF1
dragon
:
database
:
25
5
database
:
25
1
dbs
:
0,256
host
:
r-2zeucai3yj2t0f4nmz.redis.rds.aliyuncs.com
host
:
r-2zeucai3yj2t0f4nmz
pd
.redis.rds.aliyuncs.com
port
:
6380
password
:
7eoK2XehKqF1
sweet
:
database
:
25
5
database
:
25
1
dbs
:
0,256
host
:
r-2zeucai3yj2t0f4nmz.redis.rds.aliyuncs.com
host
:
r-2zeucai3yj2t0f4nmz
pd
.redis.rds.aliyuncs.com
port
:
6380
password
:
7eoK2XehKqF1
adam
:
database
:
25
5
database
:
25
1
dbs
:
0,256
host
:
r-2zeucai3yj2t0f4nmz.redis.rds.aliyuncs.com
host
:
r-2zeucai3yj2t0f4nmz
pd
.redis.rds.aliyuncs.com
port
:
6380
password
:
7eoK2XehKqF1
candy
:
database
:
25
5
database
:
25
1
dbs
:
0,256
host
:
r-2zeucai3yj2t0f4nmz.redis.rds.aliyuncs.com
host
:
r-2zeucai3yj2t0f4nmz
pd
.redis.rds.aliyuncs.com
port
:
6380
password
:
7eoK2XehKqF1
mongodb
:
host
:
39.107.71.112:270
17
port
:
270
17
user
:
admin
pwd
:
S&y$
6d*JwJ
mongodb
:
host
:
dds-2ze23697d93111041932-pub.mongodb.rds.aliyuncs.com:3717,dds-2ze23697d93111042720-pub.mongodb.rds.aliyuncs.com:37
17
port
:
37
17
user
:
root
pwd
:
Sy
6d*JwJ
service
:
adam
:
url-pay
:
...
...
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