lib/pause/redis/adapter.rb in pause-0.2.0 vs lib/pause/redis/adapter.rb in pause-0.2.1
- old
+ new
@@ -52,12 +52,17 @@
redis.zrangebyscore rate_limited_list(scope), Time.now.to_i, '+inf'
end
# For a scope, delete the entire sorted set that holds the block list.
# Also delete the original tracking information, so we don't immediately re-block the id
+ #
+ # @return count [Integer] the number of items deleted
def delete_rate_limited_keys(scope)
+ return 0 unless rate_limited_keys(scope).any?
delete_tracking_keys(scope, rate_limited_keys(scope))
- redis.del rate_limited_list(scope)
+ redis.zremrangebyscore(rate_limited_list(scope), '-inf', '+inf').tap do |_count|
+ redis.del rate_limited_list(scope)
+ end
end
def delete_rate_limited_key(scope, id)
delete_tracking_keys(scope, [id])
redis.zrem rate_limited_list(scope), id