# rack-attack v4.2.0 doesn't yet support clearing of keys.# Taken from https://github.com/kickstarter/rack-attack/issues/113classRack::Attack::Allow2Bandefself.reset(discriminator,options)findtime=options[:findtime]orraiseArgumentError,"Must pass findtime option"cache.reset_count("#{key_prefix}:count:#{discriminator}",findtime)cache.delete("#{key_prefix}:ban:#{discriminator}")endendclassRack::Attack::Cachedefreset_count(unprefixed_key,period)epoch_time=Time.now.to_i# Add 1 to expires_in to avoid timing error: http://git.io/i1PHXAexpires_in=period-(epoch_time%period)+1key="#{(epoch_time/period).to_i}:#{unprefixed_key}"delete(key)enddefdelete(unprefixed_key)store.delete("#{prefix}:#{unprefixed_key}")endendclassRack::Attack::StoreProxy::RedisStoreProxydefdelete(key,options={})self.del(key)rescueRedis::BaseErrorendend