twelvefactor-cache 1.0.2 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/twelvefactor/environment/cache.rb +1 -1
- data/lib/twelvefactor/environment/cache/redis.rb +40 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 83942a78fdade4150ff804b1e79f34b3f5c5d38b
|
4
|
+
data.tar.gz: a3f1cb3f3f99a27a5b8677aea736255283f2b925
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 590c822eba81c5ee210ed87a35317bd1b7063a3682403b311c24e8a988b0cbf293c8d8b81c6d596cb443974adc16bbb05b4ba89973e0b7e47d813622340ebbb6
|
7
|
+
data.tar.gz: ea2a26bfdb45665dd4d9791b4b9d4cdb13b336b73da300b91ec8695a9ad292edfd719fa4f1e629c1a4a1a6bf27be6a133cd74c7be4a8bc6003484058ba3fd807
|
@@ -1,8 +1,47 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
require "uri"
|
3
|
+
|
2
4
|
class Twelvefactor::Environment::Cache::Redis
|
3
5
|
def self.apply app, cache_url
|
4
6
|
config = app.config
|
5
7
|
|
6
|
-
config.cache_store =
|
8
|
+
config.cache_store = [
|
9
|
+
:redis_store,
|
10
|
+
cache_base_url(cache_url).to_s,
|
11
|
+
options(cache_url.query)
|
12
|
+
]
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.cache_base_url url
|
16
|
+
base = url.dup
|
17
|
+
base.query = nil
|
18
|
+
base
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.options query
|
22
|
+
normalize_types raw_options query
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.normalize_types options
|
26
|
+
normalized = {}
|
27
|
+
|
28
|
+
if options.key? :expires_in
|
29
|
+
normalized[:expires_in] = options[:expires_in].to_i
|
30
|
+
end
|
31
|
+
|
32
|
+
if options.key? :compress
|
33
|
+
normalized[:compress] = options[:compress] == "true"
|
34
|
+
end
|
35
|
+
|
36
|
+
options.merge normalized
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.raw_options query
|
40
|
+
return {} unless query
|
41
|
+
|
42
|
+
CGI
|
43
|
+
.parse(query)
|
44
|
+
.map { |k, val| [k.to_sym, val.first] }
|
45
|
+
.to_h
|
7
46
|
end
|
8
47
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: twelvefactor-cache
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Konstantin Burnaev
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-09-
|
11
|
+
date: 2016-09-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: twelvefactor
|