zache 0.7.0 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dbc07440cf1bc314b4a2d64f2dbd2f96509fa241f4e9e6e4f3dd5a32a0ec7adf
4
- data.tar.gz: 4cb895d3b70c72bc03366207adb245b7ca38773626e71cc118e8aae412d1b349
3
+ metadata.gz: 8dc4e7bf81e1fac197d586d7b9609133ba5de20c2183be9e49fc50e4ab018e0c
4
+ data.tar.gz: f01851cba887991e6ae63b47070ed54ba373f1a15a57ea5d60a9fe4e7a7cf8b2
5
5
  SHA512:
6
- metadata.gz: f76c45b4f213d7df68cdb261eb4ba748191a6bd61e80b90ea438c1a353b7e648efa79175662afc8ce6081b60759b617884f6dbc97d40c84decdeeb16ad17a31e
7
- data.tar.gz: e1c6a58bd8ac9d63e7da8abfcdc6fd7f729b90da5115b14006268360afa7857618af1003ef286b154529580808be75915e7b44d9e2bae1104133fd9759151a22
6
+ metadata.gz: a5c2f5d7d5d08946c741ae8c48f9ad4b84992b4a151f5450dc15f44b7c44b67ba6448cab10b795638fe3e91192e3ac5decf587b9635c1ecb846e74546ef61c23
7
+ data.tar.gz: 45f346fc252d1a44b25702165ecd35ddc2d18f4415625f9481187be0cb13282fbb57633f5168e0fc2d5c45976eeb949876582ffe42d2d5c43922823dfd27ed31
data/Gemfile CHANGED
@@ -21,4 +21,5 @@
21
21
  # SOFTWARE.
22
22
 
23
23
  source 'https://rubygems.org'
24
+ ruby '2.6.0'
24
25
  gemspec
data/lib/zache.rb CHANGED
@@ -87,17 +87,18 @@ class Zache
87
87
 
88
88
  # Gets the value from the cache by the provided key. If the value is not
89
89
  # found in the cache, it will be calculated via the provided block. If
90
- # the block is not given, an exception will be raised. The lifetime
90
+ # the block is not given, an exception will be raised (unless <tt>dirty</tt>
91
+ # is set to <tt>true</tt>). The lifetime
91
92
  # must be in seconds. The default lifetime is huge, which means that the
92
93
  # key will never be expired.
93
94
  #
94
95
  # If the <tt>dirty</tt> argument is set to <tt>true</tt>, a previously
95
96
  # calculated result will be returned if it exists and is already expired.
96
97
  def get(key, lifetime: 2**32, dirty: false)
98
+ if (dirty || @dirty) && locked? && key_expired?(key) && @hash.key?(key)
99
+ return @hash[key][:value]
100
+ end
97
101
  if block_given?
98
- if (dirty || @dirty) && locked? && key_expired?(key) && @hash.key?(key)
99
- return @hash[key][:value]
100
- end
101
102
  synchronized { calc(key, lifetime) { yield } }
102
103
  else
103
104
  rec = @hash[key]
data/test/test_zache.rb CHANGED
@@ -211,6 +211,7 @@ class ZacheTest < Minitest::Test
211
211
  end
212
212
  sleep 0.1
213
213
  Timeout.timeout(1) do
214
+ assert_equal(1, cache.get(:x, dirty: true))
214
215
  assert_equal(1, cache.get(:x, dirty: true) { 2 })
215
216
  end
216
217
  long.kill
data/zache.gemspec CHANGED
@@ -31,7 +31,7 @@ Gem::Specification.new do |s|
31
31
  s.rubygems_version = '2.5'
32
32
  s.required_ruby_version = '>=2.5'
33
33
  s.name = 'zache'
34
- s.version = '0.7.0'
34
+ s.version = '0.8.0'
35
35
  s.license = 'MIT'
36
36
  s.summary = 'In-memory Cache'
37
37
  s.description = 'Zero-footprint in-memory thread-safe cache'
@@ -46,7 +46,7 @@ Gem::Specification.new do |s|
46
46
  s.add_development_dependency 'minitest', '5.11.3'
47
47
  s.add_development_dependency 'rake', '12.3.1'
48
48
  s.add_development_dependency 'rdoc', '4.3.0'
49
- s.add_development_dependency 'rubocop', '0.60.0'
50
- s.add_development_dependency 'rubocop-rspec', '1.30.1'
49
+ s.add_development_dependency 'rubocop', '0.62.0'
50
+ s.add_development_dependency 'rubocop-rspec', '1.31.0'
51
51
  s.add_development_dependency 'threads', '0.3.0'
52
52
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zache
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-12-21 00:00:00.000000000 Z
11
+ date: 2019-01-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby
@@ -72,28 +72,28 @@ dependencies:
72
72
  requirements:
73
73
  - - '='
74
74
  - !ruby/object:Gem::Version
75
- version: 0.60.0
75
+ version: 0.62.0
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - '='
81
81
  - !ruby/object:Gem::Version
82
- version: 0.60.0
82
+ version: 0.62.0
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: rubocop-rspec
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - '='
88
88
  - !ruby/object:Gem::Version
89
- version: 1.30.1
89
+ version: 1.31.0
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - '='
95
95
  - !ruby/object:Gem::Version
96
- version: 1.30.1
96
+ version: 1.31.0
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: threads
99
99
  requirement: !ruby/object:Gem::Requirement
@@ -148,8 +148,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
148
148
  - !ruby/object:Gem::Version
149
149
  version: '0'
150
150
  requirements: []
151
- rubyforge_project:
152
- rubygems_version: 2.7.6
151
+ rubygems_version: 3.0.1
153
152
  signing_key:
154
153
  specification_version: 2
155
154
  summary: In-memory Cache