suo 0.3.4 → 0.4.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: 631845e2977ae0e7bc903eb2863820a7ff55c54760879f96268a06f66c7ea15f
4
- data.tar.gz: 5c262505f86e9a4e9fdd34df059a9c3ed76d55a596731a0178fe653ef2637f43
3
+ metadata.gz: 76af80589128e43f0f5b0664f6604f657dd6735df18e18bf6134e49aae2656cb
4
+ data.tar.gz: '0982702d597aa9d91da01f3921cabfdbdceb2e2e61961c4c7d5e2438d76883db'
5
5
  SHA512:
6
- metadata.gz: d0c52381b64f1592170dfb0c4d7dabdcb0127a097e8d9702340c3f5107dcc7bea9d04ad00b4af4944b8622cc05cba96d48ed7db21e2a704def54e2ba323dccf9
7
- data.tar.gz: fd9d8d47ff6281c2cf12f07cec4bcd7a0322ab52af80abd62db426742dfd7e3835b8a466fa7f6b585f38922c051cfddd1fa693d28980b8ca895cac021c322374
6
+ metadata.gz: 1ce36f6537803bdd00962f79e8774b779afdd91546c6b5b7fc090372d7d2bdc0c9e00b34863a1fbbb9d8f5aa2a240af6907f96ff3a415304709132e19f084be3
7
+ data.tar.gz: 3b8324c772750b34cc5d3268573d10abdce23e2026000f35117f894673e2616f5c3dc2c41d627978ae848072e20e2072c70183b81161bba884b69d61473e8ef2
@@ -0,0 +1,38 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - master
7
+ pull_request:
8
+
9
+ jobs:
10
+ build:
11
+ runs-on: ubuntu-latest
12
+ strategy:
13
+ fail-fast: false
14
+ matrix:
15
+ ruby:
16
+ - '2.5'
17
+ - '2.6'
18
+ - '2.7'
19
+ - '3.0'
20
+ - ruby-head
21
+ continue-on-error: ${{ matrix.ruby == 'ruby-head' }}
22
+ services:
23
+ memcached:
24
+ image: memcached
25
+ ports:
26
+ - 11211:11211
27
+ redis:
28
+ image: redis
29
+ ports:
30
+ - 6379:6379
31
+ steps:
32
+ - uses: actions/checkout@v2
33
+ - uses: ruby/setup-ruby@v1
34
+ with:
35
+ ruby-version: ${{ matrix.ruby }}
36
+ bundler-cache: true
37
+ - run: |
38
+ bundle exec rake
@@ -1,3 +1,10 @@
1
+ ## 0.4.0
2
+
3
+ - Monotonic clock for locks, avoiding issues with DST (thanks @doits)
4
+ - Pooled connection support (thanks @mlarraz)
5
+ - Switch to Github actions for tests (thanks @mlarraz)
6
+ - Update supported Ruby versions (thanks @mlarraz & @pat)
7
+
1
8
  ## 0.3.4
2
9
 
3
10
  - Support for connection pooling when using memcached locks, via `with` blocks using Dalli (thanks to Lev).
@@ -132,10 +132,10 @@ module Suo
132
132
  end
133
133
 
134
134
  def retry_with_timeout
135
- start = Time.now.to_f
135
+ start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
136
136
 
137
137
  retry_count.times do
138
- elapsed = Time.now.to_f - start
138
+ elapsed = Process.clock_gettime(Process::CLOCK_MONOTONIC) - start
139
139
  break if elapsed >= options[:acquisition_timeout]
140
140
 
141
141
  synchronize do
@@ -9,21 +9,31 @@ module Suo
9
9
  end
10
10
 
11
11
  def clear
12
- @client.del(@key)
12
+ with { |r| r.del(@key) }
13
13
  end
14
14
 
15
15
  private
16
16
 
17
+ def with(&block)
18
+ if @client.respond_to?(:with)
19
+ @client.with(&block)
20
+ else
21
+ yield @client
22
+ end
23
+ end
24
+
17
25
  def get
18
- [@client.get(@key), nil]
26
+ [with { |r| r.get(@key) }, nil]
19
27
  end
20
28
 
21
29
  def set(newval, _, expire: false)
22
- ret = @client.multi do |multi|
23
- if expire
24
- multi.setex(@key, @options[:ttl], newval)
25
- else
26
- multi.set(@key, newval)
30
+ ret = with do |r|
31
+ r.multi do |rr|
32
+ if expire
33
+ rr.setex(@key, @options[:ttl], newval)
34
+ else
35
+ rr.set(@key, newval)
36
+ end
27
37
  end
28
38
  end
29
39
 
@@ -31,11 +41,9 @@ module Suo
31
41
  end
32
42
 
33
43
  def synchronize
34
- @client.watch(@key) do
35
- yield
36
- end
44
+ with { |r| r.watch(@key) { yield } }
37
45
  ensure
38
- @client.unwatch
46
+ with { |r| r.unwatch }
39
47
  end
40
48
 
41
49
  def initial_set(val = BLANK_STR)
@@ -1,3 +1,3 @@
1
1
  module Suo
2
- VERSION = "0.3.4".freeze
2
+ VERSION = "0.4.0".freeze
3
3
  end
@@ -19,14 +19,14 @@ Gem::Specification.new do |spec|
19
19
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
20
20
  spec.require_paths = ["lib"]
21
21
 
22
- spec.required_ruby_version = "~> 2.0"
22
+ spec.required_ruby_version = ">= 2.5"
23
23
 
24
24
  spec.add_dependency "dalli"
25
25
  spec.add_dependency "redis"
26
26
  spec.add_dependency "msgpack"
27
27
 
28
28
  spec.add_development_dependency "bundler"
29
- spec.add_development_dependency "rake", "~> 10.0"
29
+ spec.add_development_dependency "rake", "~> 13.0"
30
30
  spec.add_development_dependency "rubocop", "~> 0.49.0"
31
31
  spec.add_development_dependency "minitest", "~> 5.5.0"
32
32
  spec.add_development_dependency "codeclimate-test-reporter", "~> 0.4.7"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: suo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.4
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Elser
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-09-04 00:00:00.000000000 Z
11
+ date: 2021-01-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dalli
@@ -72,14 +72,14 @@ dependencies:
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '10.0'
75
+ version: '13.0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '10.0'
82
+ version: '13.0'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: rubocop
85
85
  requirement: !ruby/object:Gem::Requirement
@@ -129,9 +129,9 @@ executables: []
129
129
  extensions: []
130
130
  extra_rdoc_files: []
131
131
  files:
132
+ - ".github/workflows/CI.yml"
132
133
  - ".gitignore"
133
134
  - ".rubocop.yml"
134
- - ".travis.yml"
135
135
  - CHANGELOG.md
136
136
  - Gemfile
137
137
  - LICENSE.txt
@@ -152,23 +152,23 @@ homepage: https://github.com/nickelser/suo
152
152
  licenses:
153
153
  - MIT
154
154
  metadata: {}
155
- post_install_message:
155
+ post_install_message:
156
156
  rdoc_options: []
157
157
  require_paths:
158
158
  - lib
159
159
  required_ruby_version: !ruby/object:Gem::Requirement
160
160
  requirements:
161
- - - "~>"
161
+ - - ">="
162
162
  - !ruby/object:Gem::Version
163
- version: '2.0'
163
+ version: '2.5'
164
164
  required_rubygems_version: !ruby/object:Gem::Requirement
165
165
  requirements:
166
166
  - - ">="
167
167
  - !ruby/object:Gem::Version
168
168
  version: '0'
169
169
  requirements: []
170
- rubygems_version: 3.0.3
171
- signing_key:
170
+ rubygems_version: 3.1.2
171
+ signing_key:
172
172
  specification_version: 4
173
173
  summary: Distributed locks (mutexes & semaphores) using Memcached or Redis.
174
174
  test_files:
@@ -1,9 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 2.2.6
4
- - 2.3.7
5
- - 2.4.4
6
- - 2.5.1
7
- services:
8
- - memcached
9
- - redis-server