Skip to content

Commit d57d8e6

Browse files
committed
Limiters are short lived once they hit full balance.
1 parent 9d31025 commit d57d8e6

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

src/main/java/org/barcodeapi/server/cache/CachedLimiter.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,17 @@ public CachedLimiter(boolean enforce, String caller, long requests) {
4141
this.tokensPerMilli = (requests > 0) ? ((double) requests / _DAY) : 0;
4242
}
4343

44+
/**
45+
* Short lived and can be cleaned if token balance is full.
46+
*
47+
* @return the object is short lived
48+
*/
49+
50+
@Override
51+
public boolean isShortLived() {
52+
return (tokenCount == tokenLimit);
53+
}
54+
4455
/**
4556
* Returns the caller associated with the limiter.
4657
*

0 commit comments

Comments
 (0)