Class: Rack::Dedos::Cache

Inherits:
Object
  • Object
show all
Defined in:
lib/rack/dedos/cache.rb

Defined Under Namespace

Modules: Hash, Redis

Instance Method Summary collapse

Constructor Details

#initialize(url:, key_prefix: nil, expires_in: 86400) ⇒ Cache

Returns a new instance of Cache.



7
8
9
10
11
12
13
14
# File 'lib/rack/dedos/cache.rb', line 7

def initialize(url:, key_prefix: nil, expires_in: 86400)
  @url, @key_prefix, @expires_in = url, key_prefix, expires_in
  type = url.split(':').first
  extend Object.const_get("Rack::Dedos::Cache::#{type.capitalize}")
  connect
rescue NameError
  raise(ArgumentError, "type of cache for `#{@url}' not supported")
end