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 +4 -4
- data/.github/workflows/CI.yml +38 -0
- data/CHANGELOG.md +7 -0
- data/lib/suo/client/base.rb +2 -2
- data/lib/suo/client/redis.rb +19 -11
- data/lib/suo/version.rb +1 -1
- data/suo.gemspec +2 -2
- metadata +11 -11
- data/.travis.yml +0 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 76af80589128e43f0f5b0664f6604f657dd6735df18e18bf6134e49aae2656cb
|
4
|
+
data.tar.gz: '0982702d597aa9d91da01f3921cabfdbdceb2e2e61961c4c7d5e2438d76883db'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
data/CHANGELOG.md
CHANGED
@@ -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).
|
data/lib/suo/client/base.rb
CHANGED
@@ -132,10 +132,10 @@ module Suo
|
|
132
132
|
end
|
133
133
|
|
134
134
|
def retry_with_timeout
|
135
|
-
start =
|
135
|
+
start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
136
136
|
|
137
137
|
retry_count.times do
|
138
|
-
elapsed =
|
138
|
+
elapsed = Process.clock_gettime(Process::CLOCK_MONOTONIC) - start
|
139
139
|
break if elapsed >= options[:acquisition_timeout]
|
140
140
|
|
141
141
|
synchronize do
|
data/lib/suo/client/redis.rb
CHANGED
@@ -9,21 +9,31 @@ module Suo
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def clear
|
12
|
-
|
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
|
-
[
|
26
|
+
[with { |r| r.get(@key) }, nil]
|
19
27
|
end
|
20
28
|
|
21
29
|
def set(newval, _, expire: false)
|
22
|
-
ret =
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
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
|
-
|
35
|
-
yield
|
36
|
-
end
|
44
|
+
with { |r| r.watch(@key) { yield } }
|
37
45
|
ensure
|
38
|
-
|
46
|
+
with { |r| r.unwatch }
|
39
47
|
end
|
40
48
|
|
41
49
|
def initial_set(val = BLANK_STR)
|
data/lib/suo/version.rb
CHANGED
data/suo.gemspec
CHANGED
@@ -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 = "
|
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", "~>
|
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.
|
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:
|
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: '
|
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: '
|
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.
|
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.
|
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:
|