rails-brotli-cache 0.3.10 → 0.3.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rails-brotli-cache/store.rb +15 -6
- data/lib/rails-brotli-cache/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 473f7e06756e422c9c3644f6eb8fbd97fb3c6929d74d5ede901c037c93df7db1
|
4
|
+
data.tar.gz: 25ce534d47267870cb70eb49ac849f4dc60073944372b3d26fd81a01dd360834
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e13c7a3fb0c0591dbb9dd4ccac8bf97aaf9d51ce1ec1d793fd08c678f6d8ba75b65f45f6612a12bbf8a76fc49d7865f591d466753b0d699f474fd33cc8413ab0
|
7
|
+
data.tar.gz: 4f0d2fc6e0e2e17e3212a53709fc31831bc62394daad757e1060a323dd46031daaa3ac72be67df254cfd4df8dd71751d31c70567eb217e25ec614dadc29792d3
|
@@ -58,10 +58,11 @@ module RailsBrotliCache
|
|
58
58
|
options
|
59
59
|
)
|
60
60
|
|
61
|
-
uncompressed(payload)
|
61
|
+
uncompressed(payload, options)
|
62
62
|
end
|
63
63
|
|
64
64
|
def write_multi(hash, options = nil)
|
65
|
+
options ||= {}
|
65
66
|
new_hash = hash.map do |key, val|
|
66
67
|
[
|
67
68
|
cache_key(key),
|
@@ -69,7 +70,10 @@ module RailsBrotliCache
|
|
69
70
|
]
|
70
71
|
end
|
71
72
|
|
72
|
-
@core_store.write_multi(
|
73
|
+
@core_store.write_multi(
|
74
|
+
new_hash,
|
75
|
+
options.merge(compress: false)
|
76
|
+
)
|
73
77
|
end
|
74
78
|
|
75
79
|
def read_multi(*names)
|
@@ -77,7 +81,7 @@ module RailsBrotliCache
|
|
77
81
|
names = names.map { |name| cache_key(name) }
|
78
82
|
|
79
83
|
Hash[core_store.read_multi(*names, options).map do |key, val|
|
80
|
-
[source_cache_key(key), uncompressed(val)]
|
84
|
+
[source_cache_key(key), uncompressed(val, options)]
|
81
85
|
end]
|
82
86
|
end
|
83
87
|
|
@@ -85,7 +89,9 @@ module RailsBrotliCache
|
|
85
89
|
options = names.extract_options!
|
86
90
|
names = names.map { |name| cache_key(name) }
|
87
91
|
|
88
|
-
@core_store.fetch_multi(
|
92
|
+
@core_store.fetch_multi(
|
93
|
+
*names, options.merge(compress: false)
|
94
|
+
) do |name|
|
89
95
|
compressed(yield(name), options)
|
90
96
|
end
|
91
97
|
end
|
@@ -119,8 +125,9 @@ module RailsBrotliCache
|
|
119
125
|
private
|
120
126
|
|
121
127
|
def compressed(value, options)
|
122
|
-
return value if value.is_a?(Integer)
|
123
128
|
options ||= {}
|
129
|
+
|
130
|
+
return value if value.is_a?(Integer)
|
124
131
|
serialized = Marshal.dump(value)
|
125
132
|
|
126
133
|
if serialized.bytesize >= COMPRESS_THRESHOLD && !options.fetch(:compress) == false
|
@@ -136,7 +143,9 @@ module RailsBrotliCache
|
|
136
143
|
end
|
137
144
|
end
|
138
145
|
|
139
|
-
def uncompressed(payload)
|
146
|
+
def uncompressed(payload, options)
|
147
|
+
options ||= {}
|
148
|
+
|
140
149
|
return nil unless payload.present?
|
141
150
|
|
142
151
|
return payload if payload.is_a?(Integer)
|