zache 0.5.0 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -1
- data/lib/zache.rb +7 -1
- data/test/test_zache.rb +13 -0
- data/zache.gemspec +4 -3
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8dc54638fe09360b05870981cc7b8ede8697aa4aba65121a33da31a23a65f339
|
4
|
+
data.tar.gz: 3ba83d9a9231b3facc5faf87409a4c61ab6b9638a37bcd2a29a435965e4e530d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bf689543044621801b55f6bc9800dcb5cb7f9f38193d6872485f5551cfec85957207184d24113707a39c36fae1ce1ba54a5be0b432f61077e352a7c88adc334e
|
7
|
+
data.tar.gz: 555f8d872a9ff2780cc75a9c8f782d8fdf381ad8dce75020c58183644295ffe4b2417ba4285193d02a5bd16288920e94c3b3d8512865916abaa255106cb91e1d
|
data/.rubocop.yml
CHANGED
data/lib/zache.rb
CHANGED
@@ -139,7 +139,13 @@ class Zache
|
|
139
139
|
|
140
140
|
def synchronized
|
141
141
|
if @sync
|
142
|
-
@monitor.
|
142
|
+
@monitor.synchronize do
|
143
|
+
# I don't know why, but if you remove this line, the tests will
|
144
|
+
# break. It seems to me that there is a bug in Ruby. Let's try to
|
145
|
+
# fix it or find a workaround and remove this line.
|
146
|
+
sleep 0.00001
|
147
|
+
yield
|
148
|
+
end
|
143
149
|
else
|
144
150
|
yield
|
145
151
|
end
|
data/test/test_zache.rb
CHANGED
@@ -25,8 +25,11 @@
|
|
25
25
|
require 'minitest/autorun'
|
26
26
|
require 'threads'
|
27
27
|
require 'timeout'
|
28
|
+
require 'concurrent'
|
28
29
|
require_relative '../lib/zache'
|
29
30
|
|
31
|
+
Thread.report_on_exception = true
|
32
|
+
|
30
33
|
# Cache test.
|
31
34
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
32
35
|
# Copyright:: Copyright (c) 2018 Yegor Bugayenko
|
@@ -197,4 +200,14 @@ class ZacheTest < Minitest::Test
|
|
197
200
|
end
|
198
201
|
long.kill
|
199
202
|
end
|
203
|
+
|
204
|
+
def test_fetches_multiple_keys_in_many_threads
|
205
|
+
cache = Zache.new(dirty: true)
|
206
|
+
set = Concurrent::Set.new
|
207
|
+
threads = 50
|
208
|
+
Threads.new(threads).assert(threads * 2) do |i|
|
209
|
+
set << cache.get(i) { i }
|
210
|
+
end
|
211
|
+
assert_equal(threads, set.size)
|
212
|
+
end
|
200
213
|
end
|
data/zache.gemspec
CHANGED
@@ -28,10 +28,10 @@ Gem::Specification.new do |s|
|
|
28
28
|
if s.respond_to? :required_rubygems_version=
|
29
29
|
s.required_rubygems_version = Gem::Requirement.new('>= 0')
|
30
30
|
end
|
31
|
-
s.rubygems_version = '2.
|
32
|
-
s.required_ruby_version = '>=2.
|
31
|
+
s.rubygems_version = '2.5'
|
32
|
+
s.required_ruby_version = '>=2.5'
|
33
33
|
s.name = 'zache'
|
34
|
-
s.version = '0.5.
|
34
|
+
s.version = '0.5.1'
|
35
35
|
s.license = 'MIT'
|
36
36
|
s.summary = 'In-memory Cache'
|
37
37
|
s.description = 'Zero-footprint in-memory thread-safe cache'
|
@@ -42,6 +42,7 @@ Gem::Specification.new do |s|
|
|
42
42
|
s.test_files = s.files.grep(%r{^(test)/})
|
43
43
|
s.rdoc_options = ['--charset=UTF-8']
|
44
44
|
s.extra_rdoc_files = ['README.md']
|
45
|
+
s.add_development_dependency 'concurrent-ruby', '1.1.3'
|
45
46
|
s.add_development_dependency 'minitest', '5.11.3'
|
46
47
|
s.add_development_dependency 'rake', '12.3.1'
|
47
48
|
s.add_development_dependency 'rdoc', '4.3.0'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zache
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yegor Bugayenko
|
@@ -10,6 +10,20 @@ bindir: bin
|
|
10
10
|
cert_chain: []
|
11
11
|
date: 2018-12-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: concurrent-ruby
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.1.3
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 1.1.3
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: minitest
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -127,7 +141,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
127
141
|
requirements:
|
128
142
|
- - ">="
|
129
143
|
- !ruby/object:Gem::Version
|
130
|
-
version: '2.
|
144
|
+
version: '2.5'
|
131
145
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
132
146
|
requirements:
|
133
147
|
- - ">="
|