dalli 2.7.2 → 2.7.3
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of dalli might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/History.md +14 -0
- data/README.md +18 -14
- data/Rakefile +1 -0
- data/lib/active_support/cache/dalli_store.rb +24 -15
- data/lib/dalli/client.rb +14 -10
- data/lib/dalli/ring.rb +1 -1
- data/lib/dalli/server.rb +48 -23
- data/lib/dalli/socket.rb +74 -40
- data/lib/dalli/version.rb +1 -1
- data/test/benchmark_test.rb +3 -2
- data/test/helper.rb +3 -2
- data/test/memcached_mock.rb +97 -17
- data/test/sasl/memcached.conf +1 -0
- data/test/{sasldb → sasl/sasldb} +0 -0
- data/test/test_active_support.rb +163 -61
- data/test/test_cas_client.rb +7 -7
- data/test/test_compressor.rb +4 -5
- data/test/test_dalli.rb +92 -35
- data/test/test_encoding.rb +2 -2
- data/test/test_failover.rb +44 -35
- data/test/test_network.rb +10 -0
- data/test/test_rack_session.rb +3 -3
- data/test/test_ring.rb +2 -2
- data/test/test_sasl.rb +9 -14
- data/test/test_serializer.rb +6 -7
- data/test/test_server.rb +30 -0
- metadata +7 -5
data/test/test_network.rb
CHANGED
@@ -21,6 +21,16 @@ describe 'Network' do
|
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
|
+
it 'handle connection reset with unix socket' do
|
25
|
+
socket_path = MemcachedMock::UNIX_SOCKET_PATH
|
26
|
+
memcached_mock(lambda {|sock| sock.close }, :start_unix, socket_path) do
|
27
|
+
assert_raises Dalli::RingError, :message => "No server available" do
|
28
|
+
dc = Dalli::Client.new(socket_path)
|
29
|
+
dc.get('abc')
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
24
34
|
it 'handle malformed response' do
|
25
35
|
memcached_mock(lambda {|sock| sock.write('123') }) do
|
26
36
|
assert_raises Dalli::RingError, :message => "No server available" do
|
data/test/test_rack_session.rb
CHANGED
@@ -6,11 +6,11 @@ require 'rack/mock'
|
|
6
6
|
require 'thread'
|
7
7
|
|
8
8
|
describe Rack::Session::Dalli do
|
9
|
-
Rack::Session::Dalli::DEFAULT_OPTIONS[:memcache_server] = 'localhost:19129'
|
10
9
|
|
11
10
|
before do
|
12
|
-
|
13
|
-
|
11
|
+
@port = 19129
|
12
|
+
memcached_persistent(@port)
|
13
|
+
Rack::Session::Dalli::DEFAULT_OPTIONS[:memcache_server] = "localhost:#{@port}"
|
14
14
|
|
15
15
|
# test memcache connection
|
16
16
|
Rack::Session::Dalli.new(incrementor)
|
data/test/test_ring.rb
CHANGED
@@ -5,8 +5,8 @@ describe 'Ring' do
|
|
5
5
|
describe 'a ring of servers' do
|
6
6
|
|
7
7
|
it "have the continuum sorted by value" do
|
8
|
-
servers = [stub(:
|
9
|
-
stub(:
|
8
|
+
servers = [stub(:name => "localhost:11211", :weight => 1),
|
9
|
+
stub(:name => "localhost:9500", :weight => 1)]
|
10
10
|
ring = Dalli::Ring.new(servers, {})
|
11
11
|
previous_value = 0
|
12
12
|
ring.continuum.each do |entry|
|
data/test/test_sasl.rb
CHANGED
@@ -11,8 +11,7 @@ describe 'Sasl' do
|
|
11
11
|
@server = mock()
|
12
12
|
@server.stubs(:request).returns(true)
|
13
13
|
@server.stubs(:weight).returns(1)
|
14
|
-
@server.stubs(:
|
15
|
-
@server.stubs(:port).returns("19124")
|
14
|
+
@server.stubs(:name).returns("localhost:19124")
|
16
15
|
end
|
17
16
|
|
18
17
|
describe 'without authentication credentials' do
|
@@ -26,12 +25,8 @@ describe 'Sasl' do
|
|
26
25
|
ENV['MEMCACHE_PASSWORD'] = nil
|
27
26
|
end
|
28
27
|
|
29
|
-
|
30
|
-
|
31
|
-
end
|
32
|
-
|
33
|
-
it 'gracefully handle authentication failures' do
|
34
|
-
memcached(19124, '-S') do |dc|
|
28
|
+
xit 'gracefully handle authentication failures' do
|
29
|
+
memcached_sasl_persistent do |dc|
|
35
30
|
assert_error Dalli::DalliError, /32/ do
|
36
31
|
dc.set('abc', 123)
|
37
32
|
end
|
@@ -39,9 +34,9 @@ describe 'Sasl' do
|
|
39
34
|
end
|
40
35
|
end
|
41
36
|
|
42
|
-
|
43
|
-
|
44
|
-
dc = Dalli::Client.new(
|
37
|
+
xit 'fail SASL authentication with wrong options' do
|
38
|
+
memcached_sasl_persistent do |dc, port|
|
39
|
+
dc = Dalli::Client.new("localhost:#{port}", :username => 'testuser', :password => 'testtest')
|
45
40
|
assert_error Dalli::DalliError, /32/ do
|
46
41
|
dc.set('abc', 123)
|
47
42
|
end
|
@@ -65,7 +60,7 @@ describe 'Sasl' do
|
|
65
60
|
end
|
66
61
|
|
67
62
|
xit 'pass SASL authentication' do
|
68
|
-
|
63
|
+
memcached_sasl_persistent do |dc|
|
69
64
|
# I get "Dalli::DalliError: Error authenticating: 32" in OSX
|
70
65
|
# but SASL works on Heroku servers. YMMV.
|
71
66
|
assert_equal true, dc.set('abc', 123)
|
@@ -78,8 +73,8 @@ describe 'Sasl' do
|
|
78
73
|
end
|
79
74
|
|
80
75
|
xit 'pass SASL authentication with options' do
|
81
|
-
|
82
|
-
dc = Dalli::Client.new(
|
76
|
+
memcached_sasl_persistent do |dc, port|
|
77
|
+
dc = Dalli::Client.new("localhost:#{port}", sasl_credentials)
|
83
78
|
# I get "Dalli::DalliError: Error authenticating: 32" in OSX
|
84
79
|
# but SASL works on Heroku servers. YMMV.
|
85
80
|
assert_equal true, dc.set('abc', 123)
|
data/test/test_serializer.rb
CHANGED
@@ -6,21 +6,20 @@ require 'memcached_mock'
|
|
6
6
|
describe 'Serializer' do
|
7
7
|
|
8
8
|
it 'default to Marshal' do
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
assert_equal Marshal, memcache.instance_variable_get('@ring').servers.first.serializer
|
9
|
+
memcached(29198) do |dc|
|
10
|
+
dc.set 1,2
|
11
|
+
assert_equal Marshal, dc.instance_variable_get('@ring').servers.first.serializer
|
13
12
|
end
|
14
13
|
end
|
15
14
|
|
16
15
|
it 'support a custom serializer' do
|
17
|
-
|
18
|
-
memcache = Dalli::Client.new(
|
16
|
+
memcached(29198) do |dc, port|
|
17
|
+
memcache = Dalli::Client.new("127.0.0.1:#{port}", :serializer => JSON)
|
19
18
|
memcache.set 1,2
|
20
19
|
begin
|
21
20
|
assert_equal JSON, memcache.instance_variable_get('@ring').servers.first.serializer
|
22
21
|
|
23
|
-
memcached(
|
22
|
+
memcached(21956) do |newdc|
|
24
23
|
assert newdc.set("json_test", {"foo" => "bar"})
|
25
24
|
assert_equal({"foo" => "bar"}, newdc.get("json_test"))
|
26
25
|
end
|
data/test/test_server.rb
CHANGED
@@ -2,11 +2,26 @@ require 'helper'
|
|
2
2
|
|
3
3
|
describe Dalli::Server do
|
4
4
|
describe 'hostname parsing' do
|
5
|
+
it 'handles unix socket with no weight' do
|
6
|
+
s = Dalli::Server.new('/var/run/memcached/sock')
|
7
|
+
assert_equal '/var/run/memcached/sock', s.hostname
|
8
|
+
assert_equal 1, s.weight
|
9
|
+
assert_equal :unix, s.socket_type
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'handles unix socket with a weight' do
|
13
|
+
s = Dalli::Server.new('/var/run/memcached/sock:2')
|
14
|
+
assert_equal '/var/run/memcached/sock', s.hostname
|
15
|
+
assert_equal 2, s.weight
|
16
|
+
assert_equal :unix, s.socket_type
|
17
|
+
end
|
18
|
+
|
5
19
|
it 'handles no port or weight' do
|
6
20
|
s = Dalli::Server.new('localhost')
|
7
21
|
assert_equal 'localhost', s.hostname
|
8
22
|
assert_equal 11211, s.port
|
9
23
|
assert_equal 1, s.weight
|
24
|
+
assert_equal :tcp, s.socket_type
|
10
25
|
end
|
11
26
|
|
12
27
|
it 'handles a port, but no weight' do
|
@@ -14,6 +29,7 @@ describe Dalli::Server do
|
|
14
29
|
assert_equal 'localhost', s.hostname
|
15
30
|
assert_equal 11212, s.port
|
16
31
|
assert_equal 1, s.weight
|
32
|
+
assert_equal :tcp, s.socket_type
|
17
33
|
end
|
18
34
|
|
19
35
|
it 'handles a port and a weight' do
|
@@ -21,6 +37,7 @@ describe Dalli::Server do
|
|
21
37
|
assert_equal 'localhost', s.hostname
|
22
38
|
assert_equal 11212, s.port
|
23
39
|
assert_equal 2, s.weight
|
40
|
+
assert_equal :tcp, s.socket_type
|
24
41
|
end
|
25
42
|
|
26
43
|
it 'handles ipv4 addresses' do
|
@@ -28,6 +45,7 @@ describe Dalli::Server do
|
|
28
45
|
assert_equal '127.0.0.1', s.hostname
|
29
46
|
assert_equal 11211, s.port
|
30
47
|
assert_equal 1, s.weight
|
48
|
+
assert_equal :tcp, s.socket_type
|
31
49
|
end
|
32
50
|
|
33
51
|
it 'handles ipv6 addresses' do
|
@@ -35,6 +53,7 @@ describe Dalli::Server do
|
|
35
53
|
assert_equal '::1', s.hostname
|
36
54
|
assert_equal 11211, s.port
|
37
55
|
assert_equal 1, s.weight
|
56
|
+
assert_equal :tcp, s.socket_type
|
38
57
|
end
|
39
58
|
|
40
59
|
it 'handles ipv6 addresses with port' do
|
@@ -42,6 +61,7 @@ describe Dalli::Server do
|
|
42
61
|
assert_equal '::1', s.hostname
|
43
62
|
assert_equal 11212, s.port
|
44
63
|
assert_equal 1, s.weight
|
64
|
+
assert_equal :tcp, s.socket_type
|
45
65
|
end
|
46
66
|
|
47
67
|
it 'handles ipv6 addresses with port and weight' do
|
@@ -49,6 +69,7 @@ describe Dalli::Server do
|
|
49
69
|
assert_equal '::1', s.hostname
|
50
70
|
assert_equal 11212, s.port
|
51
71
|
assert_equal 2, s.weight
|
72
|
+
assert_equal :tcp, s.socket_type
|
52
73
|
end
|
53
74
|
|
54
75
|
it 'handles a FQDN' do
|
@@ -56,6 +77,7 @@ describe Dalli::Server do
|
|
56
77
|
assert_equal 'my.fqdn.com', s.hostname
|
57
78
|
assert_equal 11211, s.port
|
58
79
|
assert_equal 1, s.weight
|
80
|
+
assert_equal :tcp, s.socket_type
|
59
81
|
end
|
60
82
|
|
61
83
|
it 'handles a FQDN with port and weight' do
|
@@ -63,6 +85,14 @@ describe Dalli::Server do
|
|
63
85
|
assert_equal 'my.fqdn.com', s.hostname
|
64
86
|
assert_equal 11212, s.port
|
65
87
|
assert_equal 2, s.weight
|
88
|
+
assert_equal :tcp, s.socket_type
|
89
|
+
end
|
90
|
+
|
91
|
+
it 'throws an exception if the hostname cannot be parsed' do
|
92
|
+
lambda { Dalli::Server.new('[]') }.must_raise Dalli::DalliError
|
93
|
+
lambda { Dalli::Server.new('my.fqdn.com:') }.must_raise Dalli::DalliError
|
94
|
+
lambda { Dalli::Server.new('my.fqdn.com:11212,:2') }.must_raise Dalli::DalliError
|
95
|
+
lambda { Dalli::Server.new('my.fqdn.com:11212:abc') }.must_raise Dalli::DalliError
|
66
96
|
end
|
67
97
|
end
|
68
98
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dalli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.7.
|
4
|
+
version: 2.7.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Perham
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-03-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|
@@ -81,7 +81,8 @@ files:
|
|
81
81
|
- test/benchmark_test.rb
|
82
82
|
- test/helper.rb
|
83
83
|
- test/memcached_mock.rb
|
84
|
-
- test/
|
84
|
+
- test/sasl/memcached.conf
|
85
|
+
- test/sasl/sasldb
|
85
86
|
- test/test_active_support.rb
|
86
87
|
- test/test_cas_client.rb
|
87
88
|
- test/test_compressor.rb
|
@@ -115,7 +116,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
115
116
|
version: '0'
|
116
117
|
requirements: []
|
117
118
|
rubyforge_project:
|
118
|
-
rubygems_version: 2.
|
119
|
+
rubygems_version: 2.4.6
|
119
120
|
signing_key:
|
120
121
|
specification_version: 4
|
121
122
|
summary: High performance memcached client for Ruby
|
@@ -123,7 +124,8 @@ test_files:
|
|
123
124
|
- test/benchmark_test.rb
|
124
125
|
- test/helper.rb
|
125
126
|
- test/memcached_mock.rb
|
126
|
-
- test/
|
127
|
+
- test/sasl/memcached.conf
|
128
|
+
- test/sasl/sasldb
|
127
129
|
- test/test_active_support.rb
|
128
130
|
- test/test_cas_client.rb
|
129
131
|
- test/test_compressor.rb
|