zache 0.13.0 → 0.13.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/rake.yml +1 -1
- data/Gemfile +3 -3
- data/LICENSE.txt +1 -1
- data/lib/zache.rb +3 -9
- data/test/test__helper.rb +1 -1
- data/test/test_zache.rb +11 -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: b87b15cc2d21dd690255c612d9e3ea5d28f1b4788cfa19c239f3bcc6b29144e1
|
4
|
+
data.tar.gz: ea6a615b74dbec67e97d1c8d5db0b467380030d01635964e25c031e13e490fcc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6e9c8cb157905d795cb96650b8f5d71cb79b5b0575e03863df23df485c9e708f4e09d552ee0330b4f78fa373c14ef232b16b574d3afb0a310ad02d2f51732f34
|
7
|
+
data.tar.gz: 97d726f208f8ac511b8ecfac2b9602bae716bec22d0b3e56e9bc77c36ccf97efaaee73ccb4d9057f071f26ea52da9afafb6eafd88f9c2e6c46f2d1c561da3e9c
|
data/.github/workflows/rake.yml
CHANGED
data/Gemfile
CHANGED
@@ -24,10 +24,10 @@ source 'https://rubygems.org'
|
|
24
24
|
gemspec
|
25
25
|
|
26
26
|
gem 'concurrent-ruby', '1.2.2', require: false
|
27
|
-
gem 'minitest', '5.
|
27
|
+
gem 'minitest', '5.19.0', require: false
|
28
28
|
gem 'rake', '13.0.6', require: false
|
29
29
|
gem 'rdoc', '6.5.0', require: false
|
30
|
-
gem 'rubocop', '1.
|
31
|
-
gem 'rubocop-rspec', '2.
|
30
|
+
gem 'rubocop', '1.55.1', require: false
|
31
|
+
gem 'rubocop-rspec', '2.23.0', require: false
|
32
32
|
gem 'simplecov', '0.22.0', require: false
|
33
33
|
gem 'threads', '0.3.0', require: false
|
data/LICENSE.txt
CHANGED
data/lib/zache.rb
CHANGED
@@ -195,17 +195,11 @@ class Zache
|
|
195
195
|
@hash[key][:value]
|
196
196
|
end
|
197
197
|
|
198
|
-
def synchronized
|
198
|
+
def synchronized(&block)
|
199
199
|
if @sync
|
200
|
-
@mutex.synchronize
|
201
|
-
# I don't know why, but if you remove this line, the tests will
|
202
|
-
# break. It seems to me that there is a bug in Ruby. Let's try to
|
203
|
-
# fix it or find a workaround and remove this line.
|
204
|
-
sleep 0.00001
|
205
|
-
yield
|
206
|
-
end
|
200
|
+
@mutex.synchronize(&block)
|
207
201
|
else
|
208
|
-
|
202
|
+
block.call
|
209
203
|
end
|
210
204
|
end
|
211
205
|
end
|
data/test/test__helper.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright (c)
|
3
|
+
# Copyright (c) 2018-2023 Yegor Bugayenko
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the 'Software'), to deal
|
data/test/test_zache.rb
CHANGED
@@ -254,7 +254,9 @@ class ZacheTest < Minitest::Test
|
|
254
254
|
cache = Zache.new(dirty: true)
|
255
255
|
set = Concurrent::Set.new
|
256
256
|
threads = 50
|
257
|
+
barrier = Concurrent::CyclicBarrier.new(threads)
|
257
258
|
Threads.new(threads).assert(threads * 2) do |i|
|
259
|
+
barrier.wait if i < threads
|
258
260
|
set << cache.get(i, lifetime: 0.001) { i }
|
259
261
|
end
|
260
262
|
assert_equal(threads, set.size)
|
@@ -264,7 +266,9 @@ class ZacheTest < Minitest::Test
|
|
264
266
|
cache = Zache.new
|
265
267
|
set = Concurrent::Set.new
|
266
268
|
threads = 50
|
269
|
+
barrier = Concurrent::CyclicBarrier.new(threads)
|
267
270
|
Threads.new(threads).assert(threads * 2) do |i|
|
271
|
+
barrier.wait if i < threads
|
268
272
|
set << cache.get(i) { i }
|
269
273
|
end
|
270
274
|
assert_equal(threads, set.size)
|
@@ -274,4 +278,11 @@ class ZacheTest < Minitest::Test
|
|
274
278
|
cache = Zache::Fake.new
|
275
279
|
assert_equal(1, cache.get(:x) { 1 })
|
276
280
|
end
|
281
|
+
|
282
|
+
def test_rethrows
|
283
|
+
cache = Zache.new
|
284
|
+
assert_raises RuntimeError do
|
285
|
+
cache.get(:hey) { raise 'intentional' }
|
286
|
+
end
|
287
|
+
end
|
277
288
|
end
|
data/zache.gemspec
CHANGED
@@ -27,7 +27,7 @@ Gem::Specification.new do |s|
|
|
27
27
|
s.required_rubygems_version = Gem::Requirement.new('>= 0') if s.respond_to? :required_rubygems_version=
|
28
28
|
s.required_ruby_version = '>=2.5'
|
29
29
|
s.name = 'zache'
|
30
|
-
s.version = '0.13.
|
30
|
+
s.version = '0.13.1'
|
31
31
|
s.license = 'MIT'
|
32
32
|
s.summary = 'In-memory Cache'
|
33
33
|
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.13.
|
4
|
+
version: 0.13.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yegor Bugayenko
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-08-01 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Zero-footprint in-memory thread-safe cache
|
14
14
|
email: yegor256@gmail.com
|