1 Star 5 Fork 2

keking / quarkus-redis-klock

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README

quarkus-redis-klock

Redis-based quarkus distributed lock extension

Quick start

  • 1、Introduce maven coordinates
        <dependency>
            <groupId>org.github.keking</groupId>
            <artifactId>quarkus-redis-klock-ext</artifactId>
            <version>1.0-SNAPSHOT</version>
        </dependency>
  • 2、Add the following configuration in the application.properties file
#klock
quarkus.klock=true
quarkus.klock.redis.database=12
quarkus.klock.redis.password=sasa
quarkus.klock.redis.address=redis://192.168.1.204:6379

By default, the switch of klock extension is turned off, and you need to use the [quarkus.klock=true] configuration to manually turn it on.

  • 3、How to use
@Singleton
public class ServiceA {

    @Klock
    public String hello( @KlockKey String name, @KlockKey(fieldName = "name") User user){
        return "hello " + name;
    }
}

As in the code example above, the klock distributed lock quarkus extension is driven by adding annotations. @klock 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 @KlockKey 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

Other resources

spring boot version:https://github.com/kekingcn/spring-boot-klock-starter

空文件

简介

quarkus的分布式锁框架 展开 收起
Java
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
Java
1
https://gitee.com/kekingcn/quarkus-redis-klock.git
git@gitee.com:kekingcn/quarkus-redis-klock.git
kekingcn
quarkus-redis-klock
quarkus-redis-klock
master

搜索帮助