This commit is contained in:
Spencer Gibb
2017-04-18 15:04:43 -06:00
parent 7672ea3d7d
commit bc4802d0d5

View File

@@ -35,7 +35,7 @@ public class RedisRateLimiter implements RateLimiter {
* @return
*/
@Override
//TODO: signature? params (tuple?). Return type, tokens left?
//TODO: signature? params (tuple?).
public Response isAllowed(String id, int replenishRate, int burstCapacity) {
try {
@@ -46,7 +46,7 @@ public class RedisRateLimiter implements RateLimiter {
List<String> keys = Arrays.asList(prefix + ".tokens", prefix + ".timestamp");
// The arguments to the LUA script. time() returns unixtime in seconds.
String[] args = new String[]{ replenishRate+"", burstCapacity +"", Instant.now().getEpochSecond()+"", "1"};
Object[] args = new String[]{ replenishRate+"", burstCapacity +"", Instant.now().getEpochSecond()+"", "1"};
// allowed, tokens_left = redis.eval(SCRIPT, keys, args)
List results = this.redisTemplate.execute(this.script, keys, args);