Code Monkey home page Code Monkey logo

quarkus-redis-klock's Introduction

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-redis-klock's People

Contributors

klboke avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.