memcached 0.6 → 0.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,6 +3,6 @@ require "#{File.dirname(__FILE__)}/../test_helper"
3
3
 
4
4
  class BindingTest < Test::Unit::TestCase
5
5
  def test_libmemcached_loaded
6
- assert_nothing_raised { Libmemcached }
6
+ assert_nothing_raised { Rlibmemcached }
7
7
  end
8
8
  end
@@ -5,7 +5,7 @@ class MemcachedTest < Test::Unit::TestCase
5
5
 
6
6
  def setup
7
7
  @servers = ['127.0.0.1:43042', '127.0.0.1:43043']
8
- @namespace = 'class_test_namespace'
8
+ @namespace = 'memcached_test_namespace'
9
9
  @cache = Memcached.new(
10
10
  @servers,
11
11
  :namespace => @namespace,
@@ -33,11 +33,27 @@ class MemcachedTest < Test::Unit::TestCase
33
33
  assert_equal 43043, cache.send(:server_structs).last.port
34
34
  end
35
35
 
36
+ def test_destroy
37
+ cache = Memcached.new @servers, :namespace => 'test'
38
+ cache.destroy
39
+ assert_raise(Memcached::ClientError) do
40
+ cache.get key
41
+ end
42
+ end
43
+
36
44
  def test_initialize_with_invalid_server_strings
37
45
  assert_raise(ArgumentError) { Memcached.new "localhost:43042" }
38
46
  assert_raise(ArgumentError) { Memcached.new "127.0.0.1:memcached" }
39
47
  assert_raise(ArgumentError) { Memcached.new "127.0.0.1:43043:1" }
40
48
  end
49
+
50
+ def test_initialize_with_missing_server
51
+ # XXX Triggers abort trap with libmemcached --enable-debug.
52
+ @cache = Memcached.new "127.0.0.1:43044"
53
+ assert_raises Memcached::SystemError do
54
+ @cache.get key
55
+ end
56
+ end
41
57
 
42
58
  def test_initialize_without_namespace
43
59
  cache = Memcached.new @servers
@@ -74,7 +90,7 @@ class MemcachedTest < Test::Unit::TestCase
74
90
  def test_get_with_namespace
75
91
  @cache.set key, @value
76
92
  result = @cache.get key, false
77
- direct_result = Libmemcached.memcached_get(
93
+ direct_result = Rlibmemcached.memcached_get(
78
94
  @cache.instance_variable_get("@struct"),
79
95
  "#{@namespace}#{key}"
80
96
  ).first
@@ -94,11 +110,11 @@ class MemcachedTest < Test::Unit::TestCase
94
110
  end
95
111
  end
96
112
 
97
- def test_truncation_issue_is_covered
113
+ def test_values_with_null_characters_are_not_truncated
98
114
  value = OpenStruct.new(:a => Object.new) # Marshals with a null \000
99
115
  @cache.set key, value
100
116
  result = @cache.get key, false
101
- non_wrapped_result = Libmemcached.memcached_get(
117
+ non_wrapped_result = Rlibmemcached.memcached_get(
102
118
  @cache.instance_variable_get("@struct"),
103
119
  "#{@namespace}#{key}"
104
120
  ).first
@@ -107,21 +123,33 @@ class MemcachedTest < Test::Unit::TestCase
107
123
 
108
124
  def test_get_invalid_key
109
125
  assert_raise(Memcached::ClientError) { @cache.get(key * 100) }
110
- assert_raise(Memcached::ClientError) { @cache.get "I'm so bad" }
126
+ # XXX Trying to get Krow to change this to ProtocolError
127
+ assert_raise(Memcached::NotFound) { @cache.get "I'm so bad" }
128
+ end
129
+
130
+ def test_get_multi_invalid_key
131
+ assert_raise(Memcached::ClientError) { @cache.get([key * 100]) }
132
+ # XXX Trying to get Krow to change this to ProtocolError
133
+ assert_equal({},
134
+ @cache.get(["I'm so bad"]))
111
135
  end
112
136
 
113
137
  def test_get_multi
114
138
  @cache.set "#{key}_1", 1
115
139
  @cache.set "#{key}_2", 2
116
- assert_equal [1, 2],
117
- @cache.get(["#{key}_1", "#{key}_2"])
140
+ assert_equal({"#{key}_1" => 1, "#{key}_2" => 2},
141
+ @cache.get(["#{key}_1", "#{key}_2"]))
118
142
  end
119
143
 
120
144
  def test_get_multi_missing
121
145
  @cache.set "#{key}_1", 1
122
146
  @cache.delete "#{key}_2" rescue nil
123
- ary = @cache.get(["#{key}_1", "#{key}_2"])
124
- assert_instance_of Memcached::NotFound, ary.last
147
+ @cache.set "#{key}_3", 3
148
+ @cache.delete "#{key}_4" rescue nil
149
+ assert_equal(
150
+ {"test_get_multi_missing_3"=>3, "test_get_multi_missing_1"=>1},
151
+ @cache.get(["#{key}_1", "#{key}_2", "#{key}_3", "#{key}_4"])
152
+ )
125
153
  end
126
154
 
127
155
  def test_set_and_get_unmarshalled
@@ -129,6 +157,26 @@ class MemcachedTest < Test::Unit::TestCase
129
157
  result = @cache.get key, false
130
158
  assert_equal @marshalled_value, result
131
159
  end
160
+
161
+ def test_get_multi_unmarshalled
162
+ @cache.set "#{key}_1", 1, 0, false
163
+ @cache.set "#{key}_2", 2, 0, false
164
+ assert_equal(
165
+ {"#{key}_1" => "1", "#{key}_2" => "2"},
166
+ @cache.get(["#{key}_1", "#{key}_2"], false)
167
+ )
168
+ end
169
+
170
+ def test_get_multi_mixed_marshalling
171
+ @cache.set "#{key}_1", 1
172
+ @cache.set "#{key}_2", 2, 0, false
173
+ assert_nothing_raised do
174
+ @cache.get(["#{key}_1", "#{key}_2"], false)
175
+ end
176
+ assert_raise(ArgumentError) do
177
+ @cache.get(["#{key}_1", "#{key}_2"])
178
+ end
179
+ end
132
180
 
133
181
  # Set
134
182
 
@@ -224,8 +272,7 @@ class MemcachedTest < Test::Unit::TestCase
224
272
  assert_equal 15, @cache.increment(key, 5)
225
273
  end
226
274
 
227
- def test_missing_increment; return
228
- # XXX Fails due to libmemcached bug
275
+ def test_missing_increment
229
276
  @cache.delete key rescue nil
230
277
  assert_raise(Memcached::NotFound) do
231
278
  @cache.increment key
@@ -242,8 +289,7 @@ class MemcachedTest < Test::Unit::TestCase
242
289
  assert_equal 5, @cache.decrement(key, 5)
243
290
  end
244
291
 
245
- def test_missing_decrement; return
246
- # XXX Fails due to libmemcached bug
292
+ def test_missing_decrement
247
293
  @cache.delete key rescue nil
248
294
  assert_raise(Memcached::NotFound) do
249
295
  @cache.decrement key
@@ -331,6 +377,12 @@ class MemcachedTest < Test::Unit::TestCase
331
377
  cache = @cache.clone
332
378
  assert_equal cache.servers, @cache.servers
333
379
  assert_not_equal cache, @cache
380
+
381
+ # Definitely check that the structs are unlinked
382
+ cache.destroy
383
+ assert_nothing_raised do
384
+ @cache.set key, @value
385
+ end
334
386
  end
335
387
 
336
388
  # Non-blocking IO
@@ -341,7 +393,7 @@ class MemcachedTest < Test::Unit::TestCase
341
393
  assert_nothing_raised do
342
394
  cache.set key, @value
343
395
  end
344
- ret = Libmemcached.memcached_set(
396
+ ret = Rlibmemcached.memcached_set(
345
397
  cache.instance_variable_get("@struct"),
346
398
  "#{@namespace}#{key}",
347
399
  @marshalled_value,
@@ -355,7 +407,7 @@ class MemcachedTest < Test::Unit::TestCase
355
407
  assert_nothing_raised do
356
408
  @nb_cache.set key, @value
357
409
  end
358
- ret = Libmemcached.memcached_set(
410
+ ret = Rlibmemcached.memcached_set(
359
411
  @nb_cache.instance_variable_get("@struct"),
360
412
  "#{@namespace}#{key}",
361
413
  @marshalled_value,
@@ -0,0 +1,72 @@
1
+
2
+ require "#{File.dirname(__FILE__)}/../test_helper"
3
+
4
+ class RailsTest < Test::Unit::TestCase
5
+
6
+ def setup
7
+ @servers = ['127.0.0.1:43042', '127.0.0.1:43043']
8
+ @namespace = 'rails_test_namespace'
9
+ @cache = Memcached::Rails.new(@servers, :namespace => @namespace)
10
+ @value = OpenStruct.new(:a => 1, :b => 2, :c => GenericClass)
11
+ @marshalled_value = Marshal.dump(@value)
12
+ end
13
+
14
+ def test_get
15
+ @cache.set key, @value
16
+ result = @cache.get key
17
+ assert_equal @value, result
18
+ end
19
+
20
+ def test_get_multi
21
+ @cache.set key, @value
22
+ result = @cache.get_multi key
23
+ assert_equal(
24
+ {key => @value},
25
+ result
26
+ )
27
+ end
28
+
29
+ def test_delete
30
+ @cache.set key, @value
31
+ assert_nothing_raised do
32
+ @cache.delete key
33
+ end
34
+ assert_nil(@cache.get(key))
35
+ end
36
+
37
+ def test_delete_missing
38
+ assert_nothing_raised do
39
+ @cache.delete key
40
+ assert_nil(@cache.delete(key))
41
+ end
42
+ end
43
+
44
+ def test_bracket_accessors
45
+ @cache[key] = @value
46
+ result = @cache[key]
47
+ assert_equal @value, result
48
+ end
49
+
50
+ def test_get_missing
51
+ @cache.delete key rescue nil
52
+ result = @cache.get key
53
+ assert_equal nil, result
54
+ end
55
+
56
+ def test_get_nil
57
+ @cache.set key, nil, 0
58
+ result = @cache.get key
59
+ assert_equal nil, result
60
+ end
61
+
62
+ def test_namespace
63
+ assert_equal @namespace, @cache.namespace
64
+ end
65
+
66
+ private
67
+
68
+ def key
69
+ caller.first[/`(.*)'/, 1]
70
+ end
71
+
72
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: memcached
3
3
  version: !ruby/object:Gem::Version
4
- version: "0.6"
4
+ version: "0.7"
5
5
  platform: ruby
6
6
  authors:
7
7
  - Evan Weaver
@@ -30,7 +30,7 @@ cert_chain:
30
30
  yZ0=
31
31
  -----END CERTIFICATE-----
32
32
 
33
- date: 2008-01-21 00:00:00 -05:00
33
+ date: 2008-02-05 00:00:00 -05:00
34
34
  default_executable:
35
35
  dependencies: []
36
36
 
@@ -43,26 +43,30 @@ extensions:
43
43
  extra_rdoc_files: []
44
44
 
45
45
  files:
46
+ - BENCHMARKS
46
47
  - CHANGELOG
48
+ - COMPATIBILITY
47
49
  - ext/extconf.rb
48
- - ext/libmemcached.i
49
- - ext/libmemcached_wrap.c
50
+ - ext/rlibmemcached.i
51
+ - ext/rlibmemcached_wrap.c
50
52
  - lib/memcached/behaviors.rb
51
53
  - lib/memcached/exceptions.rb
52
54
  - lib/memcached/integer.rb
53
55
  - lib/memcached/memcached.rb
56
+ - lib/memcached/rails.rb
54
57
  - lib/memcached.rb
55
58
  - LICENSE
56
59
  - Manifest
57
60
  - README
58
- - test/benchmark/benchmark.rb
59
- - test/benchmark/benchmark_set_get.rb
60
- - test/benchmark/profile.rb
61
+ - test/profile/benchmark.rb
62
+ - test/profile/profile.rb
63
+ - test/profile/valgrind.rb
61
64
  - test/setup.rb
62
65
  - test/teardown.rb
63
66
  - test/test_helper.rb
64
67
  - test/unit/binding_test.rb
65
68
  - test/unit/memcached_test.rb
69
+ - test/unit/rails_test.rb
66
70
  - TODO
67
71
  - memcached.gemspec
68
72
  has_rdoc: true
@@ -96,3 +100,4 @@ test_files:
96
100
  - test/test_helper.rb
97
101
  - test/unit/binding_test.rb
98
102
  - test/unit/memcached_test.rb
103
+ - test/unit/rails_test.rb
metadata.gz.sig CHANGED
Binary file
@@ -1,107 +0,0 @@
1
- %module libmemcached
2
- %{
3
- #include <libmemcached/memcached.h>
4
- %}
5
-
6
- %warnfilter(SWIGWARN_RUBY_WRONG_NAME) memcached_st;
7
- %warnfilter(SWIGWARN_RUBY_WRONG_NAME) memcached_server_st;
8
- %warnfilter(SWIGWARN_RUBY_WRONG_NAME) memcached_stat_st;
9
- %warnfilter(SWIGWARN_RUBY_WRONG_NAME) memcached_string_st;
10
- %warnfilter(SWIGWARN_RUBY_WRONG_NAME) memcached_result_st;
11
-
12
- %include "typemaps.i"
13
-
14
- // Input maps
15
- %apply unsigned short { uint8_t };
16
- %apply unsigned int { uint16_t };
17
- %apply unsigned long { uint32_t flags, uint32_t offset };
18
-
19
- %typemap(in) (void *data) {
20
- int value = FIX2INT($input);
21
- if (value == 0 || value == 1) {
22
- $1 = (void *) value;
23
- } else {
24
- // Only pass by reference for :distribution and :hash
25
- value = value - 2;
26
- $1 = &value;
27
- }
28
- };
29
-
30
- %typemap(in) (char *str, size_t len) {
31
- $1 = STR2CSTR($input);
32
- $2 = (size_t) RSTRING($input)->len;
33
- };
34
-
35
- %apply (char *str, size_t len) {
36
- (char *key, size_t key_length),
37
- (char *value, size_t value_length)
38
- };
39
-
40
- // Output maps
41
- %apply unsigned short *OUTPUT {memcached_return *error}
42
- %apply unsigned int *OUTPUT {uint32_t *flags}
43
- %apply size_t *OUTPUT {size_t *value_length}
44
- %apply unsigned long long *OUTPUT {uint64_t *value}
45
-
46
- %typemap(out) (char **) {
47
- int i;
48
- VALUE ary = rb_ary_new();
49
- $result = rb_ary_new();
50
-
51
- for(i=0; $1[i] != NULL; i++) {
52
- rb_ary_store(ary, i, rb_str_new2($1[i]));
53
- }
54
- rb_ary_push($result, ary);
55
- free($1);
56
- };
57
-
58
- %include "/opt/local/include/libmemcached/memcached.h"
59
-
60
- // Manual wrappers
61
-
62
- // SWIG likes to use SWIG_FromCharPtr instead of SWIG_FromCharPtrAndSize because of the
63
- // retval/argout split, so it truncates return values with \0 in them
64
- VALUE memcached_get_ruby_string(memcached_st *ptr, char *key, size_t key_length, uint32_t *flags, memcached_return *error);
65
- %{
66
- VALUE memcached_get_ruby_string(memcached_st *ptr, char *key, size_t key_length, uint32_t *flags, memcached_return *error) {
67
- char *svalue;
68
- size_t *value_length;
69
- svalue = memcached_get(ptr, key, key_length, value_length, flags, error);
70
- return rb_str_new(svalue, *value_length);
71
- };
72
- %}
73
-
74
- // Ruby isn't aware that the pointer is an array... there is probably a better way to do this
75
- memcached_server_st *memcached_select_server_at(memcached_st *in_ptr, int index);
76
- %{
77
- memcached_server_st *memcached_select_server_at(memcached_st *in_ptr, int index) {
78
- return &(in_ptr->hosts[index]);
79
- };
80
- %}
81
-
82
- // Same, but for stats
83
- memcached_stat_st *memcached_select_stat_at(memcached_st *in_ptr, memcached_stat_st *stat_ptr, int index);
84
- %{
85
- memcached_stat_st *memcached_select_stat_at(memcached_st *in_ptr, memcached_stat_st *stat_ptr, int index) {
86
- return &(stat_ptr[index]);
87
- };
88
- %}
89
-
90
- // Unbreak a libmemcached 0.13 deference issue
91
- void memcached_repair_server_st(memcached_st *in_ptr, memcached_server_st *host);
92
- %{
93
- void memcached_repair_server_st(memcached_st *in_ptr, memcached_server_st *host) {
94
- host->write_ptr= 0;
95
- };
96
- %}
97
-
98
- // Stub some bogus methods left in the 0.13 memcached.h header
99
- %{
100
- memcached_return memcached_mdelete(memcached_st *ptr, char **key, size_t *key_length, unsigned int number_of_keys, time_t expiration) {
101
- return;
102
- };
103
- memcached_return memcached_mdelete_by_key(memcached_st *ptr, char *master_key, size_t master_key_length,
104
- char **key, size_t *key_length, unsigned int number_of_keys, time_t expiration) {
105
- return;
106
- };
107
- %}
@@ -1,259 +0,0 @@
1
-
2
- HERE = File.dirname(__FILE__)
3
- $LOAD_PATH << "#{HERE}/../../lib/"
4
-
5
- require 'memcached'
6
- require 'benchmark'
7
- require 'rubygems'
8
- require 'memcache'
9
-
10
- # We'll use a simple @value to try to avoid spending time in Marshal,
11
- # which is a constant penalty that both clients have to pay
12
- @value = []
13
- @marshalled = Marshal.dump(@value)
14
-
15
- @opts = [
16
- ['127.0.0.1:43042', '127.0.0.1:43043'],
17
- {
18
- :buffer_requests => false,
19
- :no_block => false,
20
- :namespace => "benchmark_namespace"
21
- }
22
- ]
23
- @key1 = "Short"
24
- @key2 = "Sym1-2-3::45"*8
25
- @key3 = "Long"*40
26
- @key4 = "Medium"*8
27
-
28
- def restart_servers
29
- system("ruby #{HERE}/../setup.rb")
30
- sleep(1)
31
- end
32
-
33
-
34
- Benchmark.bm(31) do |x|
35
- restart_servers
36
-
37
- n = 1000
38
-
39
- @m = Memcached.new(
40
- @opts[0],
41
- @opts[1].merge(:no_block => true, :buffer_requests => true)
42
- )
43
- x.report("set:plain:noblock:memcached") do
44
- n.times do
45
- @m.set @key1, @marshalled, 0, false
46
- @m.set @key2, @marshalled, 0, false
47
- @m.set @key3, @marshalled, 0, false
48
- @m.set @key1, @marshalled, 0, false
49
- @m.set @key2, @marshalled, 0, false
50
- @m.set @key3, @marshalled, 0, false
51
- end
52
- end
53
- @m = Memcached.new(*@opts)
54
- x.report("set:plain:memcached") do
55
- n.times do
56
- @m.set @key1, @marshalled, 0, false
57
- @m.set @key2, @marshalled, 0, false
58
- @m.set @key3, @marshalled, 0, false
59
- @m.set @key1, @marshalled, 0, false
60
- @m.set @key2, @marshalled, 0, false
61
- @m.set @key3, @marshalled, 0, false
62
- end
63
- end
64
- @m = MemCache.new(*@opts)
65
- x.report("set:plain:memcache-client") do
66
- n.times do
67
- @m.set @key1, @marshalled, 0, true
68
- @m.set @key2, @marshalled, 0, true
69
- @m.set @key3, @marshalled, 0, true
70
- @m.set @key1, @marshalled, 0, true
71
- @m.set @key2, @marshalled, 0, true
72
- @m.set @key3, @marshalled, 0, true
73
- end
74
- end
75
-
76
- restart_servers
77
-
78
- @m = Memcached.new(
79
- @opts[0],
80
- @opts[1].merge(:no_block => true, :buffer_requests => true)
81
- )
82
- x.report("set:ruby:noblock:memcached") do
83
- n.times do
84
- @m.set @key1, @value
85
- @m.set @key2, @value
86
- @m.set @key3, @value
87
- @m.set @key1, @value
88
- @m.set @key2, @value
89
- @m.set @key3, @value
90
- end
91
- end
92
- @m = Memcached.new(*@opts)
93
- x.report("set:ruby:memcached") do
94
- n.times do
95
- @m.set @key1, @value
96
- @m.set @key2, @value
97
- @m.set @key3, @value
98
- @m.set @key1, @value
99
- @m.set @key2, @value
100
- @m.set @key3, @value
101
- end
102
- end
103
- @m = MemCache.new(*@opts)
104
- x.report("set:ruby:memcache-client") do
105
- n.times do
106
- @m.set @key1, @value
107
- @m.set @key2, @value
108
- @m.set @key3, @value
109
- @m.set @key1, @value
110
- @m.set @key2, @value
111
- @m.set @key3, @value
112
- end
113
- end
114
-
115
- @m = Memcached.new(*@opts)
116
- x.report("get:plain:memcached") do
117
- n.times do
118
- @m.get @key1, false
119
- @m.get @key2, false
120
- @m.get @key3, false
121
- @m.get @key1, false
122
- @m.get @key2, false
123
- @m.get @key3, false
124
- end
125
- end
126
- @m = MemCache.new(*@opts)
127
- x.report("get:plain:memcache-client") do
128
- n.times do
129
- @m.get @key1, true
130
- @m.get @key2, true
131
- @m.get @key3, true
132
- @m.get @key1, true
133
- @m.get @key2, true
134
- @m.get @key3, true
135
- end
136
- end
137
-
138
- @m = Memcached.new(*@opts)
139
- x.report("get:ruby:memcached") do
140
- n.times do
141
- @m.get @key1
142
- @m.get @key2
143
- @m.get @key3
144
- @m.get @key1
145
- @m.get @key2
146
- @m.get @key3
147
- end
148
- end
149
- @m = MemCache.new(*@opts)
150
- x.report("get:ruby:memcache-client") do
151
- n.times do
152
- @m.get @key1
153
- @m.get @key2
154
- @m.get @key3
155
- @m.get @key1
156
- @m.get @key2
157
- @m.get @key3
158
- end
159
- end
160
-
161
- restart_servers
162
-
163
- @m = Memcached.new(*@opts)
164
- x.report("missing:ruby:memcached") do
165
- n.times do
166
- begin @m.delete @key1; rescue Memcached::NotFound; end
167
- begin @m.get @key1; rescue Memcached::NotFound; end
168
- begin @m.delete @key2; rescue Memcached::NotFound; end
169
- begin @m.get @key2; rescue Memcached::NotFound; end
170
- begin @m.delete @key3; rescue Memcached::NotFound; end
171
- begin @m.get @key3; rescue Memcached::NotFound; end
172
- end
173
- end
174
- @m = MemCache.new(*@opts)
175
- x.report("missing:ruby:memcache-client") do
176
- n.times do
177
- begin @m.delete @key1; rescue; end
178
- begin @m.get @key1; rescue; end
179
- begin @m.delete @key2; rescue; end
180
- begin @m.get @key2; rescue; end
181
- begin @m.delete @key3; rescue; end
182
- begin @m.get @key3; rescue; end
183
- end
184
- end
185
-
186
- restart_servers
187
-
188
- @m = Memcached.new(
189
- @opts[0],
190
- @opts[1].merge(:no_block => true, :buffer_requests => true)
191
- )
192
- x.report("mixed:ruby:noblock:memcached") do
193
- n.times do
194
- @m.set @key1, @value
195
- @m.set @key2, @value
196
- @m.set @key3, @value
197
- @m.get @key1
198
- @m.get @key2
199
- @m.get @key3
200
- @m.set @key1, @value
201
- @m.get @key1
202
- @m.set @key2, @value
203
- @m.get @key2
204
- @m.set @key3, @value
205
- @m.get @key3
206
- end
207
- end
208
- @m = Memcached.new(*@opts)
209
- x.report("mixed:ruby:memcached") do
210
- n.times do
211
- @m.set @key1, @value
212
- @m.set @key2, @value
213
- @m.set @key3, @value
214
- @m.get @key1
215
- @m.get @key2
216
- @m.get @key3
217
- @m.set @key1, @value
218
- @m.get @key1
219
- @m.set @key2, @value
220
- @m.get @key2
221
- @m.set @key3, @value
222
- @m.get @key3
223
- end
224
- end
225
- @m = MemCache.new(*@opts)
226
- x.report("mixed:ruby:memcache-client") do
227
- n.times do
228
- @m.set @key1, @value
229
- @m.set @key2, @value
230
- @m.set @key3, @value
231
- @m.get @key1
232
- @m.get @key2
233
- @m.get @key3
234
- @m.set @key1, @value
235
- @m.get @key1
236
- @m.set @key2, @value
237
- @m.get @key2
238
- @m.set @key3, @value
239
- @m.get @key3
240
- end
241
- end
242
-
243
- restart_servers
244
-
245
- n = 10000
246
- Memcached::HASH_VALUES.each do |mode,|
247
- @m = Memcached.new(@opts[0], @opts[1].merge(:hash => mode))
248
- x.report("hash:#{mode}:memcached") do
249
- n.times do
250
- @m.set @key1, @marshalled, 0, false
251
- @m.get @key1, false
252
- @m.set @key2, @marshalled, 0, false
253
- @m.get @key2, false
254
- @m.set @key3, @marshalled, 0, false
255
- @m.get @key3, false
256
- end
257
- end
258
- end
259
- end