zache 0.11.0 → 0.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/zache.rb +9 -0
- data/test/test_zache.rb +9 -0
- data/zache.gemspec +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2403a36c273eae3e483b5ae85d80eed0927e18ade783dca22acbd21ec7ea04d4
|
4
|
+
data.tar.gz: '06982ecbca83f8fd07c69546615b9a04d918a6ccd4743c03716d7ef609c35842'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d1865b4876a8e2ebd39c6032be88fdb42231e57d5507f889a7fec75d270a2254c9d80557c8a6dc6a213c24354bcc6514fd226c91d618fff3bc386d7cf9f7882a
|
7
|
+
data.tar.gz: 2dd7862a048d3cf615c1b93bf1261d0a208e4fd7acd424ed2516e032b05d2ac7050fbd1f06d1c5457d36c19073e8bd6fd4ce31d22323cf101adecdf6be1820a3
|
data/lib/zache.rb
CHANGED
@@ -165,6 +165,15 @@ class Zache
|
|
165
165
|
synchronized { @hash = {} }
|
166
166
|
end
|
167
167
|
|
168
|
+
# Remove all keys that match the block.
|
169
|
+
def remove_by
|
170
|
+
synchronized do
|
171
|
+
@hash.keys.each do |k|
|
172
|
+
@hash.delete(k) if yield(k)
|
173
|
+
end
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
168
177
|
# Remove keys that are expired.
|
169
178
|
def clean
|
170
179
|
synchronized { @hash.delete_if { |_key, value| expired?(value) } }
|
data/test/test_zache.rb
CHANGED
@@ -85,6 +85,15 @@ class ZacheTest < Minitest::Test
|
|
85
85
|
assert(cache.exists?(:wey) == true)
|
86
86
|
end
|
87
87
|
|
88
|
+
def test_remove_by_block
|
89
|
+
cache = Zache.new
|
90
|
+
cache.get('first') { Random.rand }
|
91
|
+
cache.get('second') { Random.rand }
|
92
|
+
cache.remove_by { |k| k == 'first' }
|
93
|
+
assert(cache.exists?('first') == false)
|
94
|
+
assert(cache.exists?('second') == true)
|
95
|
+
end
|
96
|
+
|
88
97
|
def test_remove_key_with_sync_false
|
89
98
|
cache = Zache.new(sync: false)
|
90
99
|
cache.get(:hey) { Random.rand }
|
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.12.0'
|
35
35
|
s.license = 'MIT'
|
36
36
|
s.summary = 'In-memory Cache'
|
37
37
|
s.description = 'Zero-footprint in-memory thread-safe cache'
|
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.12.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: 2019-01-
|
11
|
+
date: 2019-01-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: concurrent-ruby
|