File tree Expand file tree Collapse file tree 1 file changed +7
-4
lines changed
src/main/java/org/barcodeapi/server/cache Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -37,21 +37,24 @@ public class LimiterCache {
3737 public static CachedLimiter getLimiter (Subscriber sub , String address ) {
3838 LibMetrics .hitMethodRunCounter ();
3939
40+ // User ID is customer or address
41+ String userID = (sub != null ) ? sub .getCustomer () : address ;
42+
4043 // Determine if limiter exists
4144 CachedLimiter limiter ;
42- if (_LIMITERS .has (address )) {
45+ if (_LIMITERS .has (userID )) {
4346
4447 // Get the existing limiter from the cache
45- limiter = (CachedLimiter ) _LIMITERS .get (address );
48+ limiter = (CachedLimiter ) _LIMITERS .get (userID );
4649 } else {
4750
4851 // Determine enforce / limits for the new limiter
4952 int limit = (sub != null ) ? sub .getLimit () : DEFLIMIT_RATE ;
5053 boolean enforce = (sub != null ) ? sub .isEnforced () : DEFLIMIT_ENFORCE ;
5154
5255 // Create a new limiter and add it to the cache
53- limiter = new CachedLimiter (enforce , address , limit );
54- _LIMITERS .put (address , limiter );
56+ limiter = new CachedLimiter (enforce , userID , limit );
57+ _LIMITERS .put (userID , limiter );
5558 }
5659
5760 // Return the limiter
You can’t perform that action at this time.
0 commit comments