Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/x-falcon/quarkus-redisson-lock
quarkus distributed lock extension based on redisson
https://github.com/x-falcon/quarkus-redisson-lock
Last synced: 15 days ago
JSON representation
quarkus distributed lock extension based on redisson
- Host: GitHub
- URL: https://github.com/x-falcon/quarkus-redisson-lock
- Owner: x-falcon
- Created: 2023-08-25T08:19:53.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-11-01T01:50:30.000Z (about 1 year ago)
- Last Synced: 2023-11-01T04:38:50.934Z (about 1 year ago)
- Language: Java
- Homepage:
- Size: 64.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# quarkus-redisson-lock
Redis-based quarkus distributed lock extension
## Quick start
- 1、Introduce maven coordinates```
io.quarkiverse.lock
quarkus-redisson-lock
0.0.1
```
- 2、Add the following configuration in the application.properties file```
#lock
quarkus.lock.redisson=true
quarkus.lock.redisson.redis.database=12quarkus.redisson.single-server-config.address=redis://127.0.0.1:6379
quarkus.redisson.single-server-config.password=password
quarkus.redisson.threads=2
quarkus.redisson.netty-threads=4
```
By default, the switch of lock extension is turned off, and you need to use the [quarkus.lock.redisson=true] configuration to manually turn it on.- 3、How to use
```
@Singleton
public class ServiceA {@Lock
public String hello( @LockKey String name, @LockKey(fieldName = "name") User user){
return "hello " + name;
}
}
```As in the code example above, the lock distributed lock quarkus extension is driven by adding annotations. @Lock indicates that a distributed lock is added to this method. The name of the lock is: (default: full class name + method name, through the name attribute Designated) + designated business Key. Use the @LockKey annotation to mark the locked business key, and try to reduce the strength of the lock while meeting business needs. If the input parameter is an object, you can use fieldName to specify an attribute value in the object to be obtained as the business Key,
The above represents the use of the name attribute value in the user object as the business key. The same business key will be locked, and different business keys will be released