File tree Expand file tree Collapse file tree
src/main/java/org/barcodeapi/server/cache Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -132,7 +132,7 @@ public String getTokenCountStr() {
132132 * @return true if limiter is unlimited
133133 */
134134 public boolean isUnlimited () {
135- return (( tokenCount == -1 ) || ! isEnforced () );
135+ return (tokenCount == -1 );
136136 }
137137
138138 /**
@@ -144,10 +144,16 @@ public double getTokenSpend() {
144144 return tokenSpend ;
145145 }
146146
147+ /**
148+ * Returns true if the token balance allows the cost spend.
149+ *
150+ * @param cost the cost of the request
151+ * @return true if balance allows spend
152+ */
147153 public boolean allowSpend (double cost ) {
148154
149- // Allow if unlimited, or balance exceeds cost
150- return (isUnlimited () || this .tokenCount > cost );
155+ // Allow if balance exceeds cost, unlimited, or not enforced
156+ return (( this .tokenCount > cost ) || isUnlimited () || ! isEnforced () );
151157 }
152158
153159 /**
You can’t perform that action at this time.
0 commit comments