zache 0.13.0 → 0.13.1

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: 52760a54efe8ed00af83cbe98b8b3b36c7e1ab04f762a99ad0380d21707dd98f
4
- data.tar.gz: aa331388655a2bba662ddb62bea69f697ab0c60a8be39a7df97b837d8ac00398
3
+ metadata.gz: b87b15cc2d21dd690255c612d9e3ea5d28f1b4788cfa19c239f3bcc6b29144e1
4
+ data.tar.gz: ea6a615b74dbec67e97d1c8d5db0b467380030d01635964e25c031e13e490fcc
5
5
  SHA512:
6
- metadata.gz: 7b688035cc5e1fd829b78284f51301e248ceb6fb7b851d1f9f519b04c6115394f170a77655eabf6d3b0c4cc64aa5a56bc5470be6aa7bfb4f2bdeced54e15ff26
7
- data.tar.gz: 853615cc3abe9002edc5cb4590981076733a6707f280b333b462ad37c2cf17dd691edd5f8ad6f4fbaf65fb5296b2e24dee2228d99250129190d009156c1056d8
6
+ metadata.gz: 6e9c8cb157905d795cb96650b8f5d71cb79b5b0575e03863df23df485c9e708f4e09d552ee0330b4f78fa373c14ef232b16b574d3afb0a310ad02d2f51732f34
7
+ data.tar.gz: 97d726f208f8ac511b8ecfac2b9602bae716bec22d0b3e56e9bc77c36ccf97efaaee73ccb4d9057f071f26ea52da9afafb6eafd88f9c2e6c46f2d1c561da3e9c
@@ -12,7 +12,7 @@ jobs:
12
12
  name: test
13
13
  strategy:
14
14
  matrix:
15
- os: [ubuntu-20.04]
15
+ os: [ubuntu-20.04, macos-12]
16
16
  ruby: [3.0, 2.7]
17
17
  runs-on: ${{ matrix.os }}
18
18
  steps:
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.18.0', require: false
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.51.0', require: false
31
- gem 'rubocop-rspec', '2.22.0', require: false
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
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2019 Yegor Bugayenko
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/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 do
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
- yield
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) 2019 Yegor Bugayenko
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.0'
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.0
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-05-15 00:00:00.000000000 Z
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