opener-property-tagger 3.3.1 → 3.3.2

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: d732e35937583e6fbad1452c2dc72f894df668979a9259c19f4a84a9557b8971
4
- data.tar.gz: 6999b3814921c0ec9cefd59b096c89b18c4ac4e9c5a9529f0fa3141c463ea306
3
+ metadata.gz: 6483ef2a01a413e280ed9555566499496748cb0b8c25ddd9853fb50165ab03f9
4
+ data.tar.gz: eb0f85d3d82aed282d21a3b51a0c75867b62c547b49fd1ceeaac374baff86111
5
5
  SHA512:
6
- metadata.gz: 0d1d7714bfeab24e5505ea3d442b423ab3fe6daa26dfe214b412add729e2544543d0ccadf078bec3d852bb3fa2b1ec541b131a064b9a2598e38bebbeb58a6061
7
- data.tar.gz: 24a4b3b4dcd85edd9249b16e79673487a174c58e7c826820c4b1a67aed56a8f92ec4e228e0d773598b3ed6ce14b5196a2163b48c63646d3442014fcfc2af561c
6
+ metadata.gz: fe31cb493644de7eaed474d9064e3f8880f229b8e05f0685aae18e730f5cd3d94c92aa403966904147b710f0e9589cffa840cf44ac83d64fc7f9c9211ffc6313
7
+ data.tar.gz: '0939965101de5ccd503bbdeae6b511552354d8f285e263b739b5d5f004ffdf03411fac5b4a97404f728bd1038f8320843c2dcb2f8ae70059eedc44e0682c4d71'
@@ -7,6 +7,8 @@ module Opener
7
7
 
8
8
  include MonitorMixin
9
9
 
10
+ UPDATE_INTERVAL = (ENV['CACHE_EXPIRE_MINS']&.to_i || 5).minutes
11
+
10
12
  def initialize
11
13
  super
12
14
 
@@ -16,13 +18,9 @@ module Opener
16
18
 
17
19
  def [] **params
18
20
  synchronize do
19
- if existing = @cache[params]
20
- existing.tap do
21
- Thread.new{ @cache[params] = cache_update existing, **params }
22
- end
23
- else
24
- @cache[params] = cache_update **params
25
- end
21
+ existing = @cache[params]
22
+ break existing if existing and existing.from > UPDATE_INTERVAL.ago
23
+ @cache[params] = cache_update existing, **params
26
24
  end
27
25
  end
28
26
  alias_method :get, :[]
@@ -31,7 +29,11 @@ module Opener
31
29
  from = Time.now
32
30
  lexicons = load_aspects cache: existing, **params
33
31
 
34
- return existing if existing and lexicons.blank?
32
+ if existing and lexicons.blank?
33
+ existing.from = from
34
+ return existing
35
+ end
36
+
35
37
  Hashie::Mash.new(
36
38
  aspects: lexicons,
37
39
  from: from,
@@ -1,7 +1,7 @@
1
1
  module Opener
2
2
  class PropertyTagger
3
3
 
4
- VERSION = '3.3.1'
4
+ VERSION = '3.3.2'
5
5
 
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opener-property-tagger
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.3.1
4
+ version: 3.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - development@olery.com