Move throttling feature from gem back to the app

This commit is contained in:
Alex Sherman 2021-11-27 14:48:10 +05:00 committed by olegphenomenon
parent 83413213d9
commit f17ef17d16
9 changed files with 230 additions and 2 deletions

View file

@ -0,0 +1,29 @@
# frozen_string_literal: true
module Shunter
module Adapters
class Redis
attr_reader :redis
def initialize(options)
@redis = ::Redis.new(options)
end
def find_counter(key)
@redis.get(key)
end
def write_counter(key)
@redis.set(key, 1)
end
def increment_counter(key)
@redis.incr(key)
end
def expire_counter(key, timespan)
@redis.expire(key, timespan)
end
end
end
end