Class: Twelvefactor::Environment::Cache::Redis
- Inherits:
-
Object
- Object
- Twelvefactor::Environment::Cache::Redis
- Defined in:
- lib/twelvefactor/environment/cache/redis.rb
Class Method Summary collapse
- .apply(app, cache_url) ⇒ Object
- .cache_base_url(url) ⇒ Object
- .normalize_types(options) ⇒ Object
- .options(query) ⇒ Object
- .raw_options(query) ⇒ Object
Class Method Details
.apply(app, cache_url) ⇒ Object
5 6 7 8 9 10 11 12 13 |
# File 'lib/twelvefactor/environment/cache/redis.rb', line 5 def self.apply app, cache_url config = app.config config.cache_store = [ :redis_store, cache_base_url(cache_url).to_s, (cache_url.query) ] end |
.cache_base_url(url) ⇒ Object
15 16 17 18 19 |
# File 'lib/twelvefactor/environment/cache/redis.rb', line 15 def self.cache_base_url url base = url.dup base.query = nil base end |
.normalize_types(options) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/twelvefactor/environment/cache/redis.rb', line 25 def self.normalize_types normalized = {} if .key? :expires_in normalized[:expires_in] = [:expires_in].to_i end if .key? :compress normalized[:compress] = [:compress] == "true" end .merge normalized end |
.options(query) ⇒ Object
21 22 23 |
# File 'lib/twelvefactor/environment/cache/redis.rb', line 21 def self. query normalize_types query end |
.raw_options(query) ⇒ Object
39 40 41 42 43 44 45 46 |
# File 'lib/twelvefactor/environment/cache/redis.rb', line 39 def self. query return {} unless query CGI .parse(query) .map { |k, val| [k.to_sym, val.first] } .to_h end |