Giter Club home page Giter Club logo

idempotent-util's Introduction

幂等小注解

一个轻量的(?)利用缓存实现的幂等注解

幂等

一段时间内,方法调用的幂等效果(返回上一次成功调用的返回值@Idempotent);

方法调用中,再次调用的处理(DoingExecutor);

目前尚不完善的从参数中取获取key(@IdempotentParam)

可扩展

缓存默认使用guava cache,可通过实现并注入Cacher,扩展使用其他缓存(如redis)

DoingExecutor 方法调用中时再次发起调用触发的executor,可处理重复提交,默认两个实现(DefaultValueDoingExecutor,DefaultExceptionDoingExecutor)分别对应bean默认值,直接抛错

代码demo

//使用幂等工具
@EnableUseIdempotent
public class TestMain {
    @Data
    public static class Foo{
        private Long id;
        private String name;
        private Integer gender;
    }

    //方法开启幂等,expireMilliSecond为幂等超时时间
    @Idempotent(value = "testMain" ,expireMilliSecond = 180000)
    public Foo test(@IdempotentParam(fields = {"id","name"}) /* 用于确定用于幂等的key,fields为空则调用对象toString方法生成key */ Foo foo){
        return foo;
    }
}

idempotent-util's People

Stargazers

Juan Antonio Breña Moral avatar  avatar

Watchers

 avatar

Forkers

hyqgod

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.