Class: WithRateLimit::Cache::Redis

Inherits:
WithRateLimit::Cache show all
Defined in:
lib/with_rate_limit/cache/redis.rb

Class Method Summary collapse

Methods inherited from WithRateLimit::Cache

#get, #set

Class Method Details

.configure {|configuration| ... } ⇒ Object

Yields:

  • (configuration)


17
18
19
20
# File 'lib/with_rate_limit/cache/redis.rb', line 17

def self.configure
  yield configuration
  return self
end

.get(key) ⇒ Object



13
14
15
# File 'lib/with_rate_limit/cache/redis.rb', line 13

def self.get(key)
  cache[key] || {}
end

.set(key, values) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/with_rate_limit/cache/redis.rb', line 5

def self.set(key, values)
  cache_data = cache
  cache_data[key] ||= {}
  cache_data[key].merge!(values)
  
  redis_client.set('with-rate-limit', JSON(cache_data))
end