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 +4 -4
- data/Gemfile +1 -0
- data/lib/zache.rb +5 -4
- data/test/test_zache.rb +1 -0
- data/zache.gemspec +3 -3
- metadata +7 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8dc4e7bf81e1fac197d586d7b9609133ba5de20c2183be9e49fc50e4ab018e0c
|
4
|
+
data.tar.gz: f01851cba887991e6ae63b47070ed54ba373f1a15a57ea5d60a9fe4e7a7cf8b2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a5c2f5d7d5d08946c741ae8c48f9ad4b84992b4a151f5450dc15f44b7c44b67ba6448cab10b795638fe3e91192e3ac5decf587b9635c1ecb846e74546ef61c23
|
7
|
+
data.tar.gz: 45f346fc252d1a44b25702165ecd35ddc2d18f4415625f9481187be0cb13282fbb57633f5168e0fc2d5c45976eeb949876582ffe42d2d5c43922823dfd27ed31
|
data/Gemfile
CHANGED
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
|
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
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.
|
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.
|
50
|
-
s.add_development_dependency 'rubocop-rspec', '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.
|
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:
|
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.
|
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.
|
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.
|
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.
|
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
|
-
|
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
|