memcached 0.19.10 → 0.20.0
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +0 -0
- data/CHANGELOG +2 -0
- data/Manifest +3 -0
- data/ext/extconf.rb +4 -0
- data/ext/libmemcached-5.patch +832 -0
- data/ext/rlibmemcached.i +17 -4
- data/ext/rlibmemcached_wrap.c +230 -26
- data/lib/memcached.rb +1 -0
- data/lib/memcached/experimental_memcached.rb +31 -0
- data/lib/memcached/memcached.rb +6 -1
- data/memcached.gemspec +5 -5
- data/test/unit/memcached_experimental_test.rb +230 -0
- metadata +9 -4
- metadata.gz.sig +0 -0
data/memcached.gemspec
CHANGED
@@ -2,17 +2,17 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{memcached}
|
5
|
-
s.version = "0.
|
5
|
+
s.version = "0.20.0"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Evan Weaver"]
|
9
9
|
s.cert_chain = ["/Users/eweaver/p/configuration/gem_certificates/evan_weaver-original-public_cert.pem"]
|
10
|
-
s.date = %q{2010-
|
10
|
+
s.date = %q{2010-08-03}
|
11
11
|
s.description = %q{An interface to the libmemcached C client.}
|
12
12
|
s.email = %q{}
|
13
13
|
s.extensions = ["ext/extconf.rb"]
|
14
|
-
s.extra_rdoc_files = ["BENCHMARKS", "CHANGELOG", "LICENSE", "README", "TODO", "lib/memcached.rb", "lib/memcached/behaviors.rb", "lib/memcached/exceptions.rb", "lib/memcached/memcached.rb", "lib/memcached/rails.rb"]
|
15
|
-
s.files = ["BENCHMARKS", "CHANGELOG", "LICENSE", "Manifest", "README", "Rakefile", "TODO", "ext/extconf.rb", "ext/libmemcached-0.32.tar.gz", "ext/libmemcached-2.patch", "ext/libmemcached-3.patch", "ext/libmemcached-4.patch", "ext/libmemcached.patch", "ext/rlibmemcached.i", "ext/rlibmemcached_wrap.c", "ext/sasl.patch", "lib/memcached.rb", "lib/memcached/auth.rb", "lib/memcached/behaviors.rb", "lib/memcached/exceptions.rb", "lib/memcached/integer.rb", "lib/memcached/memcached.rb", "lib/memcached/rails.rb", "test/profile/benchmark.rb", "test/profile/profile.rb", "test/profile/valgrind.rb", "test/setup.rb", "test/teardown.rb", "test/test_helper.rb", "test/unit/binding_test.rb", "test/unit/memcached_test.rb", "test/unit/rails_test.rb", "memcached.gemspec"]
|
14
|
+
s.extra_rdoc_files = ["BENCHMARKS", "CHANGELOG", "LICENSE", "README", "TODO", "lib/memcached.rb", "lib/memcached/behaviors.rb", "lib/memcached/exceptions.rb", "lib/memcached/experimental_memcached.rb", "lib/memcached/memcached.rb", "lib/memcached/rails.rb"]
|
15
|
+
s.files = ["BENCHMARKS", "CHANGELOG", "LICENSE", "Manifest", "README", "Rakefile", "TODO", "ext/extconf.rb", "ext/libmemcached-0.32.tar.gz", "ext/libmemcached-2.patch", "ext/libmemcached-3.patch", "ext/libmemcached-4.patch", "ext/libmemcached-5.patch", "ext/libmemcached.patch", "ext/rlibmemcached.i", "ext/rlibmemcached_wrap.c", "ext/sasl.patch", "lib/memcached.rb", "lib/memcached/auth.rb", "lib/memcached/behaviors.rb", "lib/memcached/exceptions.rb", "lib/memcached/experimental_memcached.rb", "lib/memcached/integer.rb", "lib/memcached/memcached.rb", "lib/memcached/rails.rb", "test/profile/benchmark.rb", "test/profile/profile.rb", "test/profile/valgrind.rb", "test/setup.rb", "test/teardown.rb", "test/test_helper.rb", "test/unit/binding_test.rb", "test/unit/memcached_experimental_test.rb", "test/unit/memcached_test.rb", "test/unit/rails_test.rb", "memcached.gemspec"]
|
16
16
|
s.homepage = %q{http://blog.evanweaver.com/files/doc/fauna/memcached/}
|
17
17
|
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Memcached", "--main", "README"]
|
18
18
|
s.require_paths = ["lib", "ext"]
|
@@ -20,7 +20,7 @@ Gem::Specification.new do |s|
|
|
20
20
|
s.rubygems_version = %q{1.3.6}
|
21
21
|
s.signing_key = %q{/Users/eweaver/p/configuration/gem_certificates/evan_weaver-original-private_key.pem}
|
22
22
|
s.summary = %q{An interface to the libmemcached C client.}
|
23
|
-
s.test_files = ["test/test_helper.rb", "test/unit/binding_test.rb", "test/unit/memcached_test.rb", "test/unit/rails_test.rb"]
|
23
|
+
s.test_files = ["test/test_helper.rb", "test/unit/binding_test.rb", "test/unit/memcached_experimental_test.rb", "test/unit/memcached_test.rb", "test/unit/rails_test.rb"]
|
24
24
|
|
25
25
|
if s.respond_to? :specification_version then
|
26
26
|
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
@@ -0,0 +1,230 @@
|
|
1
|
+
|
2
|
+
require File.expand_path("#{File.dirname(__FILE__)}/../test_helper")
|
3
|
+
require 'socket'
|
4
|
+
require 'mocha'
|
5
|
+
require 'benchmark'
|
6
|
+
|
7
|
+
class MemcachedExperimentalTest < Test::Unit::TestCase
|
8
|
+
|
9
|
+
def setup
|
10
|
+
@servers = ['localhost:43042', 'localhost:43043', "#{UNIX_SOCKET_NAME}0"]
|
11
|
+
|
12
|
+
# Maximum allowed prefix key size for :hash_with_prefix_key_key => false
|
13
|
+
@prefix_key = 'prefix_key_'
|
14
|
+
|
15
|
+
@options = {
|
16
|
+
:prefix_key => @prefix_key,
|
17
|
+
:hash => :default,
|
18
|
+
:distribution => :modula}
|
19
|
+
@cache = Memcached.new(@servers, @options)
|
20
|
+
|
21
|
+
@experimental_options = {
|
22
|
+
:prefix_key => @prefix_key,
|
23
|
+
:hash => :default,
|
24
|
+
:distribution => :modula,
|
25
|
+
:experimental_features => true}
|
26
|
+
@experimental_cache = Memcached.new(@servers, @experimental_options)
|
27
|
+
|
28
|
+
@experimental_cas_options = {
|
29
|
+
:prefix_key => @prefix_key,
|
30
|
+
:support_cas => true,
|
31
|
+
:experimental_features => true}
|
32
|
+
@experimental_cas_cache = Memcached.new(@servers, @experimental_cas_options)
|
33
|
+
|
34
|
+
@experimental_binary_protocol_options = {
|
35
|
+
:prefix_key => @prefix_key,
|
36
|
+
:hash => :default,
|
37
|
+
:distribution => :modula,
|
38
|
+
:experimental_features => true,
|
39
|
+
# binary_protocol does not work -- test_get, test_get, test_append, and test_missing_append will fail when it is set to true.
|
40
|
+
:binary_protocol => true}
|
41
|
+
@experimental_binary_protocol_cache = Memcached.new(@servers, @experimental_binary_protocol_options)
|
42
|
+
|
43
|
+
@value = OpenStruct.new(:a => 1, :b => 2, :c => GenericClass)
|
44
|
+
end
|
45
|
+
|
46
|
+
def server_get_len_capable
|
47
|
+
begin
|
48
|
+
value = "foobar"
|
49
|
+
@experimental_cache.set key, value, 0, false
|
50
|
+
@experimental_cache.get_len 1, key
|
51
|
+
yield
|
52
|
+
rescue Memcached::ProtocolError
|
53
|
+
# Skip tests when the server does not support the experimental get_len command.
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def test_get_len
|
58
|
+
server_get_len_capable {
|
59
|
+
value = "foobar"
|
60
|
+
@experimental_cache.set key, value, 0, false
|
61
|
+
result = @experimental_cache.get_len 1, key
|
62
|
+
assert_equal result.size, 1
|
63
|
+
assert_equal result, value[0..0]
|
64
|
+
|
65
|
+
result = @experimental_cache.get_len 2, key
|
66
|
+
assert_equal result.size, 2
|
67
|
+
assert_equal result, value[0..1]
|
68
|
+
|
69
|
+
result = @experimental_cache.get_len 5, key
|
70
|
+
assert_equal result.size, 5
|
71
|
+
assert_equal result, value[0..4]
|
72
|
+
|
73
|
+
result = @experimental_cache.get_len 6, key
|
74
|
+
assert_equal result.size, 6
|
75
|
+
assert_equal result, value
|
76
|
+
|
77
|
+
result = @experimental_cache.get_len 32, key
|
78
|
+
assert_equal result.size, 6
|
79
|
+
assert_equal result, value
|
80
|
+
}
|
81
|
+
end
|
82
|
+
|
83
|
+
def test_get_len_0_failure
|
84
|
+
server_get_len_capable {
|
85
|
+
value = "Test that we cannot get 0 bytes with a get_len call."
|
86
|
+
@experimental_cache.set key, value, 0, false
|
87
|
+
assert_raises(Memcached::Failure) do
|
88
|
+
result = @experimental_cache.get_len 0, key
|
89
|
+
end
|
90
|
+
}
|
91
|
+
end
|
92
|
+
|
93
|
+
def test_get_len_large
|
94
|
+
server_get_len_capable {
|
95
|
+
value = "Test that we can get the first 20 bytes of a string"
|
96
|
+
@experimental_cache.set key, value, 0, false
|
97
|
+
result = @experimental_cache.get_len 20, key
|
98
|
+
assert_equal result.size, 20
|
99
|
+
assert_equal result, value[0..19]
|
100
|
+
}
|
101
|
+
end
|
102
|
+
|
103
|
+
def test_get_len_packed
|
104
|
+
server_get_len_capable {
|
105
|
+
value = [1, 2, 3, 4].pack("Q*")
|
106
|
+
@experimental_cache.set key, value, 0, false
|
107
|
+
result = @experimental_cache.get_len 8, key
|
108
|
+
assert_equal [1], result.unpack("Q*")
|
109
|
+
}
|
110
|
+
end
|
111
|
+
|
112
|
+
# get_len is not supported when using the binary protocol.
|
113
|
+
# Make sure the single get variant fails appropriately.
|
114
|
+
def test_get_len_binary
|
115
|
+
server_get_len_capable {
|
116
|
+
@experimental_binary_protocol_cache.set key, @value
|
117
|
+
assert_raises(Memcached::ActionNotSupported) do
|
118
|
+
result = @experimental_binary_protocol_cache.get_len 2, key
|
119
|
+
end
|
120
|
+
}
|
121
|
+
end
|
122
|
+
|
123
|
+
# Retrieve the first 64 bits of the values for multiple keys.
|
124
|
+
def test_get_len_multi_packed
|
125
|
+
server_get_len_capable {
|
126
|
+
key_1 = "get_len_1"
|
127
|
+
value_1 = [1, 2, 3].pack("Q*")
|
128
|
+
key_2 = "get_len_missing"
|
129
|
+
key_3 = "get_len_2"
|
130
|
+
value_3 = [5, 6, 4].pack("Q*")
|
131
|
+
keys = [key_1, key_2, key_3]
|
132
|
+
@experimental_cache.set key_1, value_1, 0, false
|
133
|
+
@experimental_cache.set key_3, value_3, 0, false
|
134
|
+
assert_equal(
|
135
|
+
{key_1=>value_1[0..7], key_3=>value_3[0..7]},
|
136
|
+
@experimental_cache.get_len(8, keys)
|
137
|
+
)
|
138
|
+
}
|
139
|
+
end
|
140
|
+
|
141
|
+
# Test that the entire value is passed back when the length specified
|
142
|
+
# is larger than any of the values (e.g., 32 in the case below).
|
143
|
+
def test_get_len_multi_packed_full
|
144
|
+
server_get_len_capable {
|
145
|
+
key_1 = "get_len_1"
|
146
|
+
value_1 = [1, 2, 3].pack("Q*")
|
147
|
+
key_2 = "get_len_missing"
|
148
|
+
key_3 = "get_len_2"
|
149
|
+
value_3 = [5, 6, 4].pack("Q*")
|
150
|
+
keys = [key_1, key_2, key_3]
|
151
|
+
@experimental_cache.set key_1, value_1, 0, false
|
152
|
+
@experimental_cache.set key_3, value_3, 0, false
|
153
|
+
assert_equal(
|
154
|
+
{key_1=>value_1, key_3=>value_3},
|
155
|
+
@experimental_cache.get_len(32, keys)
|
156
|
+
)
|
157
|
+
}
|
158
|
+
end
|
159
|
+
|
160
|
+
# get_len is not supported when using the binary protocol.
|
161
|
+
# Test that the multi get variant fails appropriately.
|
162
|
+
def test_get_len_multi_packed_binary
|
163
|
+
server_get_len_capable {
|
164
|
+
key_1 = "get_len_1"
|
165
|
+
value_1 = [1, 2, 3].pack("Q*")
|
166
|
+
key_2 = "get_len_2"
|
167
|
+
value_2 = [5, 6, 4].pack("Q*")
|
168
|
+
keys = [key_1, key_2]
|
169
|
+
@experimental_binary_protocol_cache.set key_1, value_1, 0, false
|
170
|
+
@experimental_binary_protocol_cache.set key_2, value_2, 0, false
|
171
|
+
assert_raises(Memcached::ActionNotSupported) do
|
172
|
+
result = @experimental_binary_protocol_cache.get_len 2, keys
|
173
|
+
end
|
174
|
+
}
|
175
|
+
end
|
176
|
+
|
177
|
+
def test_get_len_multi_completely_missing
|
178
|
+
server_get_len_capable {
|
179
|
+
@experimental_cache.delete "#{key}_1" rescue nil
|
180
|
+
@experimental_cache.delete "#{key}_2" rescue nil
|
181
|
+
assert_equal(
|
182
|
+
{},
|
183
|
+
@experimental_cache.get_len(1, ["#{key}_1", "#{key}_2"])
|
184
|
+
)
|
185
|
+
}
|
186
|
+
end
|
187
|
+
|
188
|
+
def test_get_len_failure
|
189
|
+
server_get_len_capable {
|
190
|
+
value = "Test that we cannot use get_len without setting the :experimental_features config."
|
191
|
+
assert_raises(NoMethodError) do
|
192
|
+
result = @cache.get_len 10, key
|
193
|
+
end
|
194
|
+
}
|
195
|
+
end
|
196
|
+
|
197
|
+
def test_cas
|
198
|
+
server_get_len_capable {
|
199
|
+
# Get the first three chars of the value back.
|
200
|
+
@experimental_cas_cache.set(key, "foo_bar", 0, false)
|
201
|
+
assert_equal "foo", @experimental_cas_cache.get_len(3, key)
|
202
|
+
assert_equal "foo_bar", @experimental_cas_cache.get_len(7, key)
|
203
|
+
}
|
204
|
+
end
|
205
|
+
|
206
|
+
# Memory cleanup
|
207
|
+
|
208
|
+
def test_reset
|
209
|
+
original_struct = @cache.instance_variable_get("@struct")
|
210
|
+
assert_nothing_raised do
|
211
|
+
@cache.reset
|
212
|
+
end
|
213
|
+
assert_not_equal original_struct,
|
214
|
+
@cache.instance_variable_get("@struct")
|
215
|
+
end
|
216
|
+
|
217
|
+
private
|
218
|
+
|
219
|
+
def key
|
220
|
+
caller.first[/.*[` ](.*)'/, 1] # '
|
221
|
+
end
|
222
|
+
|
223
|
+
def stub_server(port)
|
224
|
+
socket = TCPServer.new('127.0.0.1', port)
|
225
|
+
Thread.new { socket.accept }
|
226
|
+
socket
|
227
|
+
end
|
228
|
+
|
229
|
+
end
|
230
|
+
|
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
-
-
|
8
|
-
-
|
9
|
-
version: 0.
|
7
|
+
- 20
|
8
|
+
- 0
|
9
|
+
version: 0.20.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Evan Weaver
|
@@ -35,7 +35,7 @@ cert_chain:
|
|
35
35
|
yZ0=
|
36
36
|
-----END CERTIFICATE-----
|
37
37
|
|
38
|
-
date: 2010-
|
38
|
+
date: 2010-08-03 00:00:00 -07:00
|
39
39
|
default_executable:
|
40
40
|
dependencies: []
|
41
41
|
|
@@ -54,6 +54,7 @@ extra_rdoc_files:
|
|
54
54
|
- lib/memcached.rb
|
55
55
|
- lib/memcached/behaviors.rb
|
56
56
|
- lib/memcached/exceptions.rb
|
57
|
+
- lib/memcached/experimental_memcached.rb
|
57
58
|
- lib/memcached/memcached.rb
|
58
59
|
- lib/memcached/rails.rb
|
59
60
|
files:
|
@@ -69,6 +70,7 @@ files:
|
|
69
70
|
- ext/libmemcached-2.patch
|
70
71
|
- ext/libmemcached-3.patch
|
71
72
|
- ext/libmemcached-4.patch
|
73
|
+
- ext/libmemcached-5.patch
|
72
74
|
- ext/libmemcached.patch
|
73
75
|
- ext/rlibmemcached.i
|
74
76
|
- ext/rlibmemcached_wrap.c
|
@@ -77,6 +79,7 @@ files:
|
|
77
79
|
- lib/memcached/auth.rb
|
78
80
|
- lib/memcached/behaviors.rb
|
79
81
|
- lib/memcached/exceptions.rb
|
82
|
+
- lib/memcached/experimental_memcached.rb
|
80
83
|
- lib/memcached/integer.rb
|
81
84
|
- lib/memcached/memcached.rb
|
82
85
|
- lib/memcached/rails.rb
|
@@ -87,6 +90,7 @@ files:
|
|
87
90
|
- test/teardown.rb
|
88
91
|
- test/test_helper.rb
|
89
92
|
- test/unit/binding_test.rb
|
93
|
+
- test/unit/memcached_experimental_test.rb
|
90
94
|
- test/unit/memcached_test.rb
|
91
95
|
- test/unit/rails_test.rb
|
92
96
|
- memcached.gemspec
|
@@ -130,5 +134,6 @@ summary: An interface to the libmemcached C client.
|
|
130
134
|
test_files:
|
131
135
|
- test/test_helper.rb
|
132
136
|
- test/unit/binding_test.rb
|
137
|
+
- test/unit/memcached_experimental_test.rb
|
133
138
|
- test/unit/memcached_test.rb
|
134
139
|
- test/unit/rails_test.rb
|
metadata.gz.sig
CHANGED
Binary file
|