puffing-billy 3.0.2 → 3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3d2331e867abf32f326b7c70cd9b40604bc865a122b4ae86fa2e80d937f34659
4
- data.tar.gz: 7641cae1895a3922ea7c799cfa8274fbcc119571336428649f869614df58d759
3
+ metadata.gz: 6ba63b8d1332e409066b96b5e01205be8503dee2e3bb11ad8863df3c8c5586d2
4
+ data.tar.gz: 8a8cee9e25a6c5cf5cdfc9fa5c3eb3a176827447ec41a0891351808cf1a67bca
5
5
  SHA512:
6
- metadata.gz: 2b95020cc16529fc786eb38341c4bc0ab97fa150fd8aa9b1ffae30e6a28905c54f04b80c55eda8c817f057a43937f3e1b089a18d13ef1ceda8a9e2dedbb737c9
7
- data.tar.gz: e474b6370e0f648bfda03afdd7fc2b0ad6354517d55fbc283c449e8e46609daf9cc977fa11a4c709dd2993b8abd9ca9f6c79924c30f43de39b41751d8a326b7f
6
+ metadata.gz: 93c40d01325be4deb136bec1e3f0c5f375475669dd2b44a535733bbc54976eca5d7bcce58b2688ca916303a45dbb6f7bcf2df3bc20fdcdb7a18ab1c7e0bcda4f
7
+ data.tar.gz: 4b66a6c0242bed4283dafdb5d7a68a9dc9357ab5ce75e87824afd0dd1b68fecf686863b242c95b8ddc239efb003423c9dd7687ff042228a16cbf1aad0b2e8fe2
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ v3.0.3, 2022-05-31
2
+ -------------------
3
+ * Only calculate cache scope and key if request is cacheable [#324](https://github.com/oesmith/puffing-billy/pull/324)
4
+
1
5
  v3.0.2, 2022-02-16
2
6
  -------------------
3
7
  * Add rake tasks inside files DSL in gemspec [#321](https://github.com/oesmith/puffing-billy/pull/321)
data/lib/billy/cache.rb CHANGED
@@ -15,6 +15,8 @@ module Billy
15
15
  end
16
16
 
17
17
  def cached?(method, url, body)
18
+ return false unless Billy.config.cache
19
+
18
20
  # Only log the key the first time it's looked up (in this method)
19
21
  key = key(method, url, body, true)
20
22
  !@cache[key].nil? || persisted?(key)
@@ -25,9 +25,6 @@ module Billy
25
25
  port: Billy.config.proxied_request_port }} )
26
26
  end
27
27
 
28
- cache_scope = Billy::Cache.instance.scope
29
- cache_key = Billy::Cache.instance.key(method.downcase, url, body)
30
-
31
28
  req = EventMachine::HttpRequest.new(url, opts)
32
29
  req = req.send(method.downcase, build_request_options(url, headers, body))
33
30
 
@@ -47,6 +44,9 @@ module Billy
47
44
  end
48
45
 
49
46
  if cacheable?(url, response[:headers], response[:status])
47
+ cache_scope = Billy::Cache.instance.scope
48
+ cache_key = Billy::Cache.instance.key(method.downcase, url, body)
49
+
50
50
  Billy::Cache.instance.store(
51
51
  cache_key,
52
52
  cache_scope,
data/lib/billy/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Billy
2
- VERSION = '3.0.2'
2
+ VERSION = '3.0.3'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: puffing-billy
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.2
4
+ version: 3.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Olly Smith
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-02-16 00:00:00.000000000 Z
11
+ date: 2022-06-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec