-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat($Redis): integrate with Redis distributed lock for concurrency c…
…ontrol integrate with Redis distributed lock for concurrency control BREAKING CHANGE: integrate with Redis distributed lock for concurrency control
- Loading branch information
1 parent
0f4dff5
commit 85bf9bc
Showing
3 changed files
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
...ava/com/jmsoftware/maf/springcloudstarter/configuration/DistributedLockConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.jmsoftware.maf.springcloudstarter.configuration; | ||
|
||
import lombok.extern.slf4j.Slf4j; | ||
import lombok.val; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.data.redis.connection.RedisConnectionFactory; | ||
import org.springframework.integration.redis.util.RedisLockRegistry; | ||
|
||
/** | ||
* <h1>DistributedLockConfiguration</h1> | ||
* <p> | ||
* Change description here. | ||
* | ||
* @author Johnny Miller (鍾俊), email: johnnysviva@outlook.com, 2/23/22 7:51 AM | ||
**/ | ||
@Slf4j | ||
@ConditionalOnClass({RedisLockRegistry.class}) | ||
public class DistributedLockConfiguration { | ||
private static final String REGISTRY_KEY = "redis-lock"; | ||
|
||
@Bean(destroyMethod = "destroy") | ||
public RedisLockRegistry redisLockRegistry(RedisConnectionFactory redisConnectionFactory) { | ||
val redisLockRegistry = new RedisLockRegistry(redisConnectionFactory, REGISTRY_KEY); | ||
log.warn("RedisLockRegistry bean is created. {}", redisLockRegistry); | ||
return redisLockRegistry; | ||
} | ||
} |