- Implemented on top of ideas of well known algorithm, which are by de-facto standard for rate limiting in the IT industry.
- Effective lock-free implementation, Bucket4j is good scalable for multithreading case.
- Absolutely non-compromise precision, Bucket4j does not operate with floats or doubles, all calculation are performed in the integer arithmetic, this feature protects end users from calculation errors involved by rounding.
- Ability to switch from one JVM to cluster in two lines of code. Using Bucket4j you are able to limiting something in the cluster of JVMs.
Since release 1.2 the
Bucket4j
supports any GRID solution which compatible with JCache API (JSR 107) specification. Just use your favorite grid including Hazelcast, Ignite, Coherence, Infinispan or any other. - Ability to specify more than one bandwidth per bucket. For example you can limit 1000 events per hours but not often then 100 events per minute.
The items placed in recommended to read order:
- Basic-usage - examples of basic usage, just start from here and most likely you will skip the rest items below.
- Brief overview of token-bucket algorithm - the brief overview of token-bucket algorithm.
- Jcache integration - documentation and examples about usage
Bucket4j
with in-memory grids which supportsJCache API (JSR 107)
specification. - Advanced usage - examples of advanced usage.
- Spring Boot Starter - third-party integration developed by @MarcGiffing.
Documentation for previous versions:
- 1.0
10 May 2015
First version of bucket4j library - 1.1
2 Mar 2017
Removing intrusive support of Oracle Coherence - 1.2
3 Mar 2017
Support of JCache and java 8 - 1.3
23 Mar 2017
Support different styles of synchronization for local bucket
Download compiled jar, sources, javadocs
git clone https://github.com/vladimir-bukhtoyarov/bucket4j.git
cd bucket4j
mvn clean install
The Bucket4j is distributed through both JCenter and Maven Central, use any of them:
<dependency>
<groupId>com.github.vladimir-bukhtoyarov</groupId>
<artifactId>bucket4j-core</artifactId>
<version>2.1.0</version>
</dependency>
To use JCache extension you also need to add following dependency:
<dependency>
<groupId>com.github.vladimir-bukhtoyarov</groupId>
<artifactId>bucket4j-jcache</artifactId>
<version>2.1.0</version>
</dependency>
Feel free to ask in the gitter chat
Copyright 2015-2017 Vladimir Bukhtoyarov Licensed under the Apache Software License, Version 2.0: http://www.apache.org/licenses/LICENSE-2.0.