记得上下班打卡 | 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
57011822
Commit
57011822
authored
Nov 10, 2021
by
jiangxiulong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
JxlMathUtil
parent
78a26b88
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
60 additions
and
59 deletions
+60
-59
JxlMathUtil.java
...weet/src/main/java/com/liquidnet/service/JxlMathUtil.java
+60
-59
No files found.
liquidnet-bus-service/liquidnet-service-sweet/src/main/java/com/liquidnet/service/JxlMathUtil.java
View file @
57011822
//
package com.liquidnet.service;
package
com
.
liquidnet
.
service
;
//
//
import com.liquidnet.common.cache.redis.config.RedisConfig;
import
com.liquidnet.common.cache.redis.config.RedisConfig
;
//
import lombok.extern.slf4j.Slf4j;
import
lombok.extern.slf4j.Slf4j
;
//
/
//
**
/**
//
* @author AnJiabin <anjiabin@zhengzai.tv>
* @author AnJiabin <anjiabin@zhengzai.tv>
//
* @version V1.0
* @version V1.0
//
* @Description: TODO
* @Description: TODO
//
* @class: MathUtil
* @class: MathUtil
//
* @Package com.liquidnet.common.cache.redis.util
* @Package com.liquidnet.common.cache.redis.util
//
* @Copyright: LightNet @ Copyright (c) 2021
* @Copyright: LightNet @ Copyright (c) 2021
//
* @date 2021/8/10 18:03
* @date 2021/8/10 18:03
//
*/
*/
//
@Slf4j
@Slf4j
//
public class JxlMathUtil {
public
class
JxlMathUtil
{
//
public static int getIndex(String key){
public
static
int
getIndex
(
String
key
){
//
log.debug("MathUtil.getIndex key:{} hashcode:{}",key,key.hashCode());
log
.
debug
(
"MathUtil.getIndex key:{} hashcode:{}"
,
key
,
key
.
hashCode
());
// int defaultDb = RedisConfig.defaultDb
;
int
defaultDb
=
0
;
// int totalDbs = RedisConfig.totalDbs
;
int
totalDbs
=
256
;
//
//
totalDbs = 256;
// totalDbs = 256;
//
if(totalDbs==1){
if
(
totalDbs
==
1
){
//
log.info("only one db : {} ",defaultDb);
log
.
info
(
"only one db : {} "
,
defaultDb
);
//
return defaultDb;
return
defaultDb
;
//
}
}
//
int mod = 250;
int
mod
=
250
;
//
if(totalDbs > 1 && totalDbs < 256){
if
(
totalDbs
>
1
&&
totalDbs
<
256
){
//
if(totalDbs==16){
if
(
totalDbs
==
16
){
//
mod = 15;
mod
=
15
;
//
}else{
}
else
{
//
mod = totalDbs - 1;
mod
=
totalDbs
-
1
;
//
}
}
//
}
}
//
long value = Long.valueOf(key.hashCode());
long
value
=
Long
.
valueOf
(
key
.
hashCode
());
//
int hash=(int)(value ^ (value >>> 32));
int
hash
=(
int
)(
value
^
(
value
>>>
32
));
//
int index=hash % mod;
int
index
=
hash
%
mod
;
//
log.debug("MathUtil.getIndex key:{} index:{}",key,index);
log
.
debug
(
"MathUtil.getIndex key:{} index:{}"
,
key
,
index
);
//
return index;
return
index
;
//
}
}
//
//
public static void main(String[] args) {
public
static
void
main
(
String
[]
args
)
{
//
/*RedisConfig redisConfig = new RedisConfig();
/*RedisConfig redisConfig = new RedisConfig();
//
redisConfig.getRedisTemplateByDb(MathUtil.getIndex("1"));*/
redisConfig.getRedisTemplateByDb(MathUtil.getIndex("1"));*/
// getIndex("kylin:performances:id:296290722991104003684701");
// getIndex("kylin:performances:id:296290722991104003684701");
//// getIndex("kylin:order:coupon:id:397983761946132487870836");
getIndex
(
"sweet:integralActivity:prizeNum:activityId:499142611246284803622253:prizeId:499142823268352009440982"
);
//// getIndex("sweet:integralActivity:list");
// getIndex("kylin:order:coupon:id:397983761946132487870836");
//// getIndex("kylin:order:id:325244198036357120519956");
// getIndex("sweet:integralActivity:list");
//// getIndex("kylin:performances:roadShowId:5936345");
// getIndex("kylin:order:id:325244198036357120519956");
//// getIndex("kylin:performances:roadShowId:570");
// getIndex("kylin:performances:roadShowId:5936345");
//// getIndex("kylin:order:refund:address");
// getIndex("kylin:performances:roadShowId:570");
//// getIndex("basicServices:upushList:IOS");
// getIndex("kylin:order:refund:address");
//// getIndex("basicServices:upushList:Android");
// getIndex("basicServices:upushList:IOS");
//// getIndex("basicServices:zhengzaiAppVersionsAndroid");
// getIndex("basicServices:upushList:Android");
//// getIndex("basicServices:zhengzaiAppVersionsIos");
// getIndex("basicServices:zhengzaiAppVersionsAndroid");
//// getIndex("basicServices:zhengzaiCheckAppVersionsAndroid");
// getIndex("basicServices:zhengzaiAppVersionsIos");
//// getIndex("basicServices:zhengzaiCheckAppVersionsIos");
// getIndex("basicServices:zhengzaiCheckAppVersionsAndroid");
//// getIndex("kylin:performances_inventory:ticket:id:245075780722810880782444:surplusGeneral");
// getIndex("basicServices:zhengzaiCheckAppVersionsIos");
//// getIndex("kylin:performances:notice");
// getIndex("kylin:performances_inventory:ticket:id:245075780722810880782444:surplusGeneral");
// }
// getIndex("kylin:performances:notice");
//}
}
\ No newline at end of file
}
\ No newline at end of file
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