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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4686166302287dae583252d66cd7d1a265a9fea6f5cc6c68f321249a9fe04d5e
4
- data.tar.gz: 7d960c4c23fa027e623f033a3ba618802d43d6d65a8b863c1ce99eb297fdacff
3
+ metadata.gz: 2403a36c273eae3e483b5ae85d80eed0927e18ade783dca22acbd21ec7ea04d4
4
+ data.tar.gz: '06982ecbca83f8fd07c69546615b9a04d918a6ccd4743c03716d7ef609c35842'
5
5
  SHA512:
6
- metadata.gz: ef2ef6578ec02be0572e92f1e45ff104f9039bb3b189c5f2647c80d69a0c8f82a27bdd2f3238770b09c877b2424ace681b59f232713c6457cec07cf716ea85bf
7
- data.tar.gz: f1651dd070af026762a57f2a1b34f45cceae1bac625a4b0bd5c32f1492615cf4e54f12fddaa8d50f19f84679b7d2096285670b839b79d190b50844531a865b8b
6
+ metadata.gz: d1865b4876a8e2ebd39c6032be88fdb42231e57d5507f889a7fec75d270a2254c9d80557c8a6dc6a213c24354bcc6514fd226c91d618fff3bc386d7cf9f7882a
7
+ data.tar.gz: 2dd7862a048d3cf615c1b93bf1261d0a208e4fd7acd424ed2516e032b05d2ac7050fbd1f06d1c5457d36c19073e8bd6fd4ce31d22323cf101adecdf6be1820a3
@@ -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) } }
@@ -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 }
@@ -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.11.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.11.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-10 00:00:00.000000000 Z
11
+ date: 2019-01-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby