-
Notifications
You must be signed in to change notification settings - Fork 24
test pr #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
exec:获取锁或执行异常时,优先保证服务可用.
解决redis并发Bug
*/ | ||
@Override | ||
public boolean execute() { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
删除第一行评论
@Override | ||
public boolean execute() { | ||
|
||
BoundValueOperations<String, String> boundValueOps = redisTemplate.boundValueOps(route); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
删除第2行评论
public boolean execute() { | ||
|
||
BoundValueOperations<String, String> boundValueOps = redisTemplate.boundValueOps(route); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
删除第3行评论
|
||
BoundValueOperations<String, String> boundValueOps = redisTemplate.boundValueOps(route); | ||
|
||
if(boundValueOps.setIfAbsent("1")){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
删除第4行评论
BoundValueOperations<String, String> boundValueOps = redisTemplate.boundValueOps(route); | ||
|
||
if(boundValueOps.setIfAbsent("1")){ | ||
boundValueOps.expire(1000, TimeUnit.MILLISECONDS); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
删除第5行评论
|
||
if(boundValueOps.setIfAbsent("1")){ | ||
boundValueOps.expire(1000, TimeUnit.MILLISECONDS); | ||
System.out.println( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
删除第6行评论
if(boundValueOps.setIfAbsent("1")){ | ||
boundValueOps.expire(1000, TimeUnit.MILLISECONDS); | ||
System.out.println( | ||
"add value to redis,key=" + route + ",second=" + (System.currentTimeMillis() / 1000)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
删除第7行评论
|
||
@Bean | ||
public DistributedLimiter distributedLimiter(){ | ||
return new DistributedLimiter(stringRedisTemplate) ; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
删除行上面是非Diff区域
this.route = route ; | ||
this.limit = limit ; | ||
this.route = route; | ||
this.limit = limit; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
连续4个变更行
|
||
public DistributedLimiter( | ||
RedisTemplate<String, String> redisTemplate) { | ||
public DistributedLimiter(RedisTemplate redisTemplate) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
连续3个变更行
RT