suo 0.2.0 → 0.2.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
  SHA1:
3
- metadata.gz: 413b62af263af5a28c0fbf5691b30963f42f0883
4
- data.tar.gz: 546c7fd3bac7b2222f6d9d2701a456c6a2aa6e36
3
+ metadata.gz: ef6a0837cc8be9a03a3767df546c630adf1e74cf
4
+ data.tar.gz: d2fefd52a16706479a3f62b4a89557ece8e74672
5
5
  SHA512:
6
- metadata.gz: eca791c152ebf80a02307f7af951eb352b8891e1bf8ec75e674ca9db772c317df2bcdb63bc880f1c844a52f0246d0448aab6937bae9d914bf0c85c886714f61d
7
- data.tar.gz: 721d0b259f9c87338227ec70e5d2a20b72672ab71d0402984c1e1afceb2dc71eaa3e274a50e1760ef4764220c0184a4994c0c37c6b4760579a346c91b55de6ab
6
+ metadata.gz: 4dc9fa8f2377e19efce5d6d4d009a145214360fd51efac442aaabcd9ba9077e49bdbad7828304c9aab9a273ad76b017c6fadce7bccf83c1d0897d31c63a0333d
7
+ data.tar.gz: a0de3ab597fc8d61fe6f47f2b239aeaa11baf9d6cde481481840f96a8f673150a9d10db13e53796cd552cafceb01fbedffaa4160228686b6396335444dbf64e5
@@ -1,3 +1,7 @@
1
+ ## 0.2.1
2
+
3
+ - Fix bug when dealing with real-world Redis error conditions.
4
+
1
5
  ## 0.2.0
2
6
 
3
7
  - Refactor class methods into instance methods to simplify implementation.
data/lib/suo.rb CHANGED
@@ -1,2 +1,16 @@
1
+ require "securerandom"
2
+ require "monitor"
3
+
4
+ require "dalli"
5
+ require "dalli/cas/client"
6
+
7
+ require "redis"
8
+
9
+ require "msgpack"
10
+
1
11
  require "suo/version"
2
- require "suo/clients"
12
+
13
+ require "suo/errors"
14
+ require "suo/client/base"
15
+ require "suo/client/memcached"
16
+ require "suo/client/redis"
@@ -49,7 +49,7 @@ module Suo
49
49
  val, cas = get(key)
50
50
 
51
51
  if val.nil?
52
- set_initial(key)
52
+ initial_set(key)
53
53
  next
54
54
  end
55
55
 
@@ -94,7 +94,7 @@ module Suo
94
94
  val, cas = get(key)
95
95
 
96
96
  if val.nil?
97
- set_initial(key)
97
+ initial_set(key)
98
98
  next
99
99
  end
100
100
 
@@ -123,7 +123,7 @@ module Suo
123
123
  fail NotImplementedError
124
124
  end
125
125
 
126
- def set_initial(key) # rubocop:disable Lint/UnusedMethodArgument
126
+ def initial_set(key) # rubocop:disable Lint/UnusedMethodArgument
127
127
  fail NotImplementedError
128
128
  end
129
129
 
@@ -20,7 +20,7 @@ module Suo
20
20
  @client.set_cas(key, newval, cas)
21
21
  end
22
22
 
23
- def set_initial(key)
23
+ def initial_set(key)
24
24
  @client.set(key, "")
25
25
  end
26
26
  end
@@ -21,7 +21,7 @@ module Suo
21
21
  multi.set(key, newval)
22
22
  end
23
23
 
24
- ret[0] == "OK"
24
+ ret && ret[0] == "OK"
25
25
  end
26
26
 
27
27
  def synchronize(key)
@@ -32,7 +32,7 @@ module Suo
32
32
  @client.unwatch
33
33
  end
34
34
 
35
- def set_initial(key)
35
+ def initial_set(key)
36
36
  @client.set(key, "")
37
37
  end
38
38
  end
@@ -1,3 +1,3 @@
1
1
  module Suo
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
@@ -10,7 +10,7 @@ module ClientTests
10
10
  end
11
11
  end
12
12
 
13
- def test_class_single_resource_locking
13
+ def test_single_resource_locking
14
14
  lock1 = @client.lock(TEST_KEY, 1)
15
15
  refute_nil lock1
16
16
 
@@ -27,7 +27,7 @@ module ClientTests
27
27
  assert_equal false, locked
28
28
  end
29
29
 
30
- def test_class_multiple_resource_locking
30
+ def test_multiple_resource_locking
31
31
  lock1 = @client.lock(TEST_KEY, 2)
32
32
  refute_nil lock1
33
33
 
@@ -72,8 +72,9 @@ module ClientTests
72
72
  output = Queue.new
73
73
  threads = []
74
74
 
75
- threads << Thread.new { @client.lock(TEST_KEY, 2) { output << "One"; sleep 2 } }
76
- threads << Thread.new { @client.lock(TEST_KEY, 2) { output << "Two"; sleep 2 } }
75
+ threads << Thread.new { @client.lock(TEST_KEY, 2) { output << "One"; sleep 0.5 } }
76
+ threads << Thread.new { @client.lock(TEST_KEY, 2) { output << "Two"; sleep 0.5 } }
77
+ sleep 0.1
77
78
  threads << Thread.new { @client.lock(TEST_KEY, 2) { output << "Three" } }
78
79
 
79
80
  threads.map(&:join)
@@ -86,10 +87,10 @@ module ClientTests
86
87
  ret.sort!
87
88
 
88
89
  assert_equal 0, output.size
89
- assert_equal ["One", "Two"], ret
90
+ assert_equal %w(One Two), ret
90
91
  end
91
92
 
92
- def test_instance_multiple_resource_locking
93
+ def test_block_multiple_resource_locking
93
94
  success_counter = Queue.new
94
95
  failure_counter = Queue.new
95
96
 
@@ -97,7 +98,7 @@ module ClientTests
97
98
 
98
99
  100.times.map do |i|
99
100
  Thread.new do
100
- success = @client.lock(TEST_KEY, 50) do
101
+ success = client.lock(TEST_KEY, 50) do
101
102
  sleep(3)
102
103
  success_counter << i
103
104
  end
@@ -110,7 +111,7 @@ module ClientTests
110
111
  assert_equal 50, failure_counter.size
111
112
  end
112
113
 
113
- def test_instance_multiple_resource_locking_longer_timeout
114
+ def test_block_multiple_resource_locking_longer_timeout
114
115
  success_counter = Queue.new
115
116
  failure_counter = Queue.new
116
117
 
@@ -6,4 +6,3 @@ require "minitest/autorun"
6
6
  require "minitest/benchmark"
7
7
 
8
8
  ENV["SUO_TEST"] = "true"
9
-
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: suo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Elser
@@ -131,7 +131,6 @@ files:
131
131
  - lib/suo/client/base.rb
132
132
  - lib/suo/client/memcached.rb
133
133
  - lib/suo/client/redis.rb
134
- - lib/suo/clients.rb
135
134
  - lib/suo/errors.rb
136
135
  - lib/suo/version.rb
137
136
  - suo.gemspec
@@ -1,14 +0,0 @@
1
- require "securerandom"
2
- require "monitor"
3
-
4
- require "dalli"
5
- require "dalli/cas/client"
6
-
7
- require "redis"
8
-
9
- require "msgpack"
10
-
11
- require "suo/errors"
12
- require "suo/client/base"
13
- require "suo/client/memcached"
14
- require "suo/client/redis"