memcached 0.8 → 0.8.1

Sign up to get free protection for your applications and to get access to all the features.
data.tar.gz.sig CHANGED
Binary file
data/BENCHMARKS CHANGED
@@ -10,35 +10,35 @@ You can easily run your own benchmarks, as long as you have memcached itself on
10
10
  These benchmarks were run on 32-bit Intel OS X 10.4:
11
11
 
12
12
  user system total real
13
- set:plain:noblock:memcached 0.110000 0.020000 0.130000 ( 0.306181)
14
- set:plain:memcached 0.260000 0.330000 0.590000 ( 1.332132)
15
- set:plain:memcache-client 46.830000 0.640000 47.470000 ( 49.439137)
16
- set:ruby:noblock:memcached 0.190000 0.020000 0.210000 ( 0.344947)
17
- set:ruby:memcached 0.360000 0.340000 0.700000 ( 1.502977)
18
- set:ruby:caffeine 5.480000 0.890000 6.370000 ( 7.224237)
19
- set:ruby:memcache-client 47.460000 0.630000 48.090000 ( 50.113758)
20
- get:plain:memcached 0.340000 0.340000 0.680000 ( 1.346579)
21
- get:plain:memcache-client 47.480000 0.600000 48.080000 ( 49.662450)
22
- get:ruby:memcached 0.400000 0.350000 0.750000 ( 1.464317)
23
- get:ruby:caffeine 5.410000 0.900000 6.310000 ( 7.142927)
24
- get:ruby:memcache-client 47.600000 0.720000 48.320000 ( 51.090209)
25
- missing:ruby:memcached 0.750000 0.380000 1.130000 ( 1.786494)
26
- missing:ruby:caffeine 5.130000 0.870000 6.000000 ( 6.854605)
27
- missing:ruby:memcache-client 46.870000 0.610000 47.480000 ( 49.318730)
28
- mixed:ruby:noblock:memcached 0.740000 0.840000 1.580000 ( 2.747368)
29
- mixed:ruby:memcached 0.740000 0.680000 1.420000 ( 2.825775)
30
- mixed:ruby:caffeine 9.670000 1.770000 11.440000 ( 13.203683)
31
- mixed:ruby:memcache-client 94.910000 1.380000 96.290000 (101.312885)
32
- hash:fnv1a_64:memcached 1.170000 1.360000 2.530000 ( 5.374056)
33
- hash:crc:memcached 1.160000 1.330000 2.490000 ( 5.422227)
34
- hash:fnv1_32:memcached 1.150000 1.350000 2.500000 ( 5.356032)
35
- hash:fnv1_64:memcached 1.200000 1.370000 2.570000 ( 5.487689)
36
- hash:default:memcached 1.160000 1.360000 2.520000 ( 5.506072)
37
- hash:md5:memcached 1.240000 1.320000 2.560000 ( 5.930740)
38
- hash:hsieh:memcached 1.150000 1.370000 2.520000 ( 5.505223)
39
- hash:ketama:memcached 1.230000 1.340000 2.570000 ( 5.759874)
40
- hash:fnv1a_32:memcached 1.150000 1.360000 2.510000 ( 5.562683)
41
-
13
+ set:plain:noblock:memcached 0.120000 0.020000 0.140000 ( 0.368084)
14
+ set:plain:memcached 0.270000 0.340000 0.610000 ( 1.499177)
15
+ set:plain:memcache-client 47.310000 0.670000 47.980000 ( 50.628096)
16
+ set:ruby:noblock:memcached 0.190000 0.010000 0.200000 ( 0.354409)
17
+ set:ruby:memcached 0.380000 0.340000 0.720000 ( 1.454480)
18
+ set:ruby:caffeine 5.570000 0.890000 6.460000 ( 7.456010)
19
+ set:ruby:memcache-client 48.340000 0.770000 49.110000 ( 52.899929)
20
+ get:plain:memcached 0.350000 0.330000 0.680000 ( 1.410108)
21
+ get:plain:memcache-client 48.000000 0.670000 48.670000 ( 51.532252)
22
+ get:ruby:memcached 0.410000 0.340000 0.750000 ( 1.432786)
23
+ get:ruby:caffeine 5.480000 0.910000 6.390000 ( 7.269396)
24
+ get:ruby:memcache-client 48.320000 0.770000 49.090000 ( 52.790661)
25
+ missing:ruby:memcached 0.420000 0.370000 0.790000 ( 1.458207)
26
+ missing:ruby:memcached:inline 0.430000 0.370000 0.800000 ( 1.633660)
27
+ missing:ruby:caffeine 5.270000 0.900000 6.170000 ( 7.442863)
28
+ missing:ruby:memcache-client 48.270000 0.750000 49.020000 ( 53.028126)
29
+ mixed:ruby:noblock:memcached 0.760000 0.900000 1.660000 ( 2.935532)
30
+ mixed:ruby:memcached 0.770000 0.670000 1.440000 ( 2.891710)
31
+ mixed:ruby:caffeine 9.850000 1.780000 11.630000 ( 13.339650)
32
+ mixed:ruby:memcache-client 97.490000 1.460000 98.950000 (105.600490)
33
+ hash:fnv1_32:memcached 1.270000 1.350000 2.620000 ( 5.557949)
34
+ hash:fnv1_64:memcached 1.200000 1.350000 2.550000 ( 5.446442)
35
+ hash:hsieh:memcached 1.210000 1.360000 2.570000 ( 5.365423)
36
+ hash:md5:memcached 1.250000 1.340000 2.590000 ( 5.457329)
37
+ hash:default:memcached 1.220000 1.340000 2.560000 ( 5.455361)
38
+ hash:ketama:memcached 1.170000 1.350000 2.520000 ( 5.361789)
39
+ hash:fnv1a_64:memcached 1.240000 1.350000 2.590000 ( 5.389261)
40
+ hash:fnv1a_32:memcached 1.180000 1.350000 2.530000 ( 5.332386)
41
+ hash:crc:memcached 1.220000 1.350000 2.570000 ( 5.460113)
42
42
 
43
43
  == x86-64 Linux
44
44
 
data/CHANGELOG CHANGED
@@ -1,4 +1,6 @@
1
1
 
2
+ v0.8.1. Disable NotFound backtraces for speed (Blaine Cook).
3
+
2
4
  v0.8. CAS support. Update to libmemcached 0.16.
3
5
 
4
6
  v0.7.2. Auto-repair unprintable characters and too-long keys; improve performance of namespacing operation.
@@ -43,14 +43,7 @@ Subclasses correspond one-to-one with server response strings or libmemcached er
43
43
 
44
44
  =end
45
45
  class Error < RuntimeError
46
- end
47
-
48
- class SynchronizationError < RuntimeError
49
- end
50
-
51
- # Raised if a method depends on functionality not yet completed in libmemcached.
52
- class NotImplemented < NoMethodError
53
- end
46
+ end
54
47
 
55
48
  #:stopdoc:
56
49
 
@@ -58,7 +51,7 @@ Subclasses correspond one-to-one with server response strings or libmemcached er
58
51
  private
59
52
  def camelize(string)
60
53
  string.downcase.gsub('/', ' or ').split(' ').map {|s| s.capitalize}.join
61
- end
54
+ end
62
55
  end
63
56
 
64
57
  EXCEPTIONS = []
@@ -72,6 +65,25 @@ Subclasses correspond one-to-one with server response strings or libmemcached er
72
65
  EXCEPTIONS << exception_class
73
66
  end
74
67
 
68
+ class NotFound
69
+ def self.remove_backtraces
70
+ class_eval do
71
+ def set_backtrace(*args); []; end
72
+ alias :backtrace :set_backtrace
73
+ end
74
+ end
75
+
76
+ def self.restore_backtraces
77
+ class_eval do
78
+ begin
79
+ remove_method :set_backtrace
80
+ remove_method :backtrace
81
+ rescue NameError
82
+ end
83
+ end
84
+ end
85
+ end
86
+
75
87
  # Verify library version
76
88
  # XXX Waiting on libmemcached 0.14
77
89
 
@@ -13,7 +13,8 @@ class Memcached
13
13
  :buffer_requests => false,
14
14
  :support_cas => false,
15
15
  :tcp_nodelay => false,
16
- :namespace => nil
16
+ :show_not_found_backtraces => false,
17
+ :namespace => nil
17
18
  }
18
19
 
19
20
  # :sort_hosts => false # XXX No effect due to libmemcached 0.16 bug
@@ -43,6 +44,7 @@ Valid option parameters are:
43
44
  <tt>:tcp_nodelay</tt>:: Turns on the no-delay feature for connecting sockets. Accepts <tt>true</tt> or <tt>false</tt>. Performance may or may not change, depending on your system.
44
45
  <tt>:no_block</tt>:: Whether to use non-blocking, asynchronous IO for writes. Accepts <tt>true</tt> or <tt>false</tt>.
45
46
  <tt>:buffer_requests</tt>:: Whether to use an internal write buffer. Accepts <tt>true</tt> or <tt>false</tt>. Calling <tt>get</tt> or closing the connection will force the buffer to flush. Note that <tt>:buffer_requests</tt> might not work well without <tt>:no_block</tt> also enabled.
47
+ <tt>:show_not_found_backtraces</tt>:: Whether <b>Memcached::NotFound</b> exceptions should include backtraces. Generating backtraces is slow, so this is off by default. Turn it on to ease debugging.
46
48
 
47
49
  Please note that when non-blocking IO is enabled, setter and deleter methods do not raise on errors. For example, if you try to set an invalid key with <tt>:no_block => true</tt>, it will appear to succeed. The actual setting of the key occurs after libmemcached has returned control to your program, so there is no way to backtrack and raise the exception.
48
50
 
@@ -65,7 +67,9 @@ Please note that when non-blocking IO is enabled, setter and deleter methods do
65
67
  # Behaviors
66
68
  @options = DEFAULTS.merge(opts)
67
69
  options.each do |option, value|
68
- set_behavior(option, value) unless option == :namespace
70
+ unless [:namespace, :show_not_found_backtraces].include? option
71
+ set_behavior(option, value)
72
+ end
69
73
  end
70
74
 
71
75
  # Make sure :buffer_requests uses :no_block
@@ -78,6 +82,16 @@ Please note that when non-blocking IO is enabled, setter and deleter methods do
78
82
  raise ArgumentError, "Invalid namespace" if options[:namespace].to_s =~ / /
79
83
  @namespace = options[:namespace].to_s
80
84
  @namespace_size = @namespace.size
85
+
86
+ # Not found exceptions
87
+ # Note that these have global effects since the NotFound class itself is modified. You should only
88
+ # be enabling the backtrace for debugging purposes, so it's not really a big deal.
89
+ if options[:show_not_found_backtraces]
90
+ NotFound.restore_backtraces
91
+ else
92
+ NotFound.remove_backtraces
93
+ end
94
+
81
95
  end
82
96
 
83
97
  # Return the array of server strings used to configure this instance.
data/memcached.gemspec CHANGED
@@ -1,16 +1,16 @@
1
1
 
2
- # Gem::Specification for Memcached-0.8
2
+ # Gem::Specification for Memcached-0.8.1
3
3
  # Originally generated by Echoe
4
4
 
5
5
  Gem::Specification.new do |s|
6
6
  s.name = %q{memcached}
7
- s.version = "0.8"
7
+ s.version = "0.8.1"
8
8
 
9
9
  s.specification_version = 2 if s.respond_to? :specification_version=
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
12
  s.authors = ["Evan Weaver"]
13
- s.date = %q{2008-02-18}
13
+ s.date = %q{2008-02-21}
14
14
  s.description = %q{An interface to the libmemcached C client.}
15
15
  s.email = %q{}
16
16
  s.extensions = ["ext/extconf.rb"]
@@ -2,6 +2,8 @@
2
2
  HERE = File.dirname(__FILE__)
3
3
  $LOAD_PATH << "#{HERE}/../../lib/"
4
4
 
5
+ require 'memcached'
6
+
5
7
  require 'benchmark'
6
8
  require 'rubygems'
7
9
 
@@ -23,347 +25,390 @@ ARGV.grep(/--with-(\w+)/) do
23
25
  end
24
26
  end
25
27
 
26
- # We'll use a simple @value to try to avoid spending time in Marshal,
27
- # which is a constant penalty that both clients have to pay
28
- @value = []
29
- @marshalled = Marshal.dump(@value)
30
-
31
- @opts = [
32
- ['127.0.0.1:43042', '127.0.0.1:43043'],
33
- {
34
- :buffer_requests => false,
35
- :no_block => false,
36
- :namespace => "benchmark_namespace"
37
- }
38
- ]
39
- @key1 = "Short"
40
- @key2 = "Sym1-2-3::45"*8
41
- @key3 = "Long"*40
42
- @key4 = "Medium"*8
28
+ recursion = ARGV.grep(/--recursion/).first[/(\d+)/, 1].to_i rescue 0
43
29
 
44
- def restart_servers
45
- system("ruby #{HERE}/../setup.rb")
46
- sleep(1)
47
- end
30
+ class Bench
48
31
 
49
- restart_servers
32
+ def initialize(recursion)
50
33
 
51
- Benchmark.bm(31) do |x|
52
-
53
- n = 2500
34
+ @recursion = recursion
35
+ puts "Recursion level is #{@recursion}"
36
+
37
+ # We'll use a simple @value to try to avoid spending time in Marshal,
38
+ # which is a constant penalty that both clients have to pay
39
+ @value = []
40
+ @marshalled = Marshal.dump(@value)
41
+
42
+ @opts = [
43
+ ['127.0.0.1:43042', '127.0.0.1:43043'],
44
+ {
45
+ :buffer_requests => false,
46
+ :no_block => false,
47
+ :namespace => "benchmark_namespace"
48
+ }
49
+ ]
50
+ @key1 = "Short"
51
+ @key2 = "Sym1-2-3::45"*8
52
+ @key3 = "Long"*40
53
+ @key4 = "Medium"*8
54
+
55
+ restart_servers
56
+ end
54
57
 
55
- if defined? Memcached
56
- @m = Memcached.new(
57
- @opts[0],
58
- @opts[1].merge(:no_block => true, :buffer_requests => true)
59
- )
60
- x.report("set:plain:noblock:memcached") do
61
- n.times do
62
- @m.set @key1, @marshalled, 0, false
63
- @m.set @key2, @marshalled, 0, false
64
- @m.set @key3, @marshalled, 0, false
65
- @m.set @key1, @marshalled, 0, false
66
- @m.set @key2, @marshalled, 0, false
67
- @m.set @key3, @marshalled, 0, false
68
- end
69
- end
70
- @m = Memcached.new(*@opts)
71
- x.report("set:plain:memcached") do
72
- n.times do
73
- @m.set @key1, @marshalled, 0, false
74
- @m.set @key2, @marshalled, 0, false
75
- @m.set @key3, @marshalled, 0, false
76
- @m.set @key1, @marshalled, 0, false
77
- @m.set @key2, @marshalled, 0, false
78
- @m.set @key3, @marshalled, 0, false
79
- end
80
- end # if false
58
+ def run(level = @recursion)
59
+ if level > 0
60
+ run_inner(level - 1)
61
+ else
62
+ benchmark
63
+ end
81
64
  end
82
- # Not supported by Caffeine
83
- if defined? MemCache
84
- @m = MemCache.new(*@opts)
85
- x.report("set:plain:memcache-client") do
86
- n.times do
87
- @m.set @key1, @marshalled, 0, true
88
- @m.set @key2, @marshalled, 0, true
89
- @m.set @key3, @marshalled, 0, true
90
- @m.set @key1, @marshalled, 0, true
91
- @m.set @key2, @marshalled, 0, true
92
- @m.set @key3, @marshalled, 0, true
93
- end
94
- end
65
+
66
+ def run_inner(level)
67
+ run(level)
68
+ end
69
+
70
+ private
71
+
72
+ def restart_servers
73
+ system("ruby #{HERE}/../setup.rb")
74
+ sleep(1)
95
75
  end
96
76
 
97
- # restart_servers
98
-
99
-
100
- if defined? Memcached
101
- @m = Memcached.new(
102
- @opts[0],
103
- @opts[1].merge(:no_block => true, :buffer_requests => true)
104
- )
105
- x.report("set:ruby:noblock:memcached") do
106
- n.times do
107
- @m.set @key1, @value
108
- @m.set @key2, @value
109
- @m.set @key3, @value
110
- @m.set @key1, @value
111
- @m.set @key2, @value
112
- @m.set @key3, @value
77
+ def benchmark
78
+ Benchmark.bm(31) do |x|
79
+
80
+ n = 2500
81
+
82
+ if defined? Memcached
83
+ @m = Memcached.new(
84
+ @opts[0],
85
+ @opts[1].merge(:no_block => true, :buffer_requests => true)
86
+ )
87
+ x.report("set:plain:noblock:memcached") do
88
+ n.times do
89
+ @m.set @key1, @marshalled, 0, false
90
+ @m.set @key2, @marshalled, 0, false
91
+ @m.set @key3, @marshalled, 0, false
92
+ @m.set @key1, @marshalled, 0, false
93
+ @m.set @key2, @marshalled, 0, false
94
+ @m.set @key3, @marshalled, 0, false
95
+ end
96
+ end
97
+ @m = Memcached.new(*@opts)
98
+ x.report("set:plain:memcached") do
99
+ n.times do
100
+ @m.set @key1, @marshalled, 0, false
101
+ @m.set @key2, @marshalled, 0, false
102
+ @m.set @key3, @marshalled, 0, false
103
+ @m.set @key1, @marshalled, 0, false
104
+ @m.set @key2, @marshalled, 0, false
105
+ @m.set @key3, @marshalled, 0, false
106
+ end
107
+ end # if false
113
108
  end
114
- end
115
- @m = Memcached.new(*@opts)
116
- x.report("set:ruby:memcached") do
117
- n.times do
118
- @m.set @key1, @value
119
- @m.set @key2, @value
120
- @m.set @key3, @value
121
- @m.set @key1, @value
122
- @m.set @key2, @value
123
- @m.set @key3, @value
109
+ # Not supported by Caffeine
110
+ if defined? MemCache
111
+ @m = MemCache.new(*@opts)
112
+ x.report("set:plain:memcache-client") do
113
+ n.times do
114
+ @m.set @key1, @marshalled, 0, true
115
+ @m.set @key2, @marshalled, 0, true
116
+ @m.set @key3, @marshalled, 0, true
117
+ @m.set @key1, @marshalled, 0, true
118
+ @m.set @key2, @marshalled, 0, true
119
+ @m.set @key3, @marshalled, 0, true
120
+ end
121
+ end
124
122
  end
125
- end # if false
126
- end
127
- if defined? Caffeine
128
- @m = Caffeine::MemCache.new(@opts[1]); @m.servers = @opts[0]
129
- x.report("set:ruby:caffeine") do
130
- n.times do
131
- @m.set @key1, @value
132
- @m.set @key2, @value
133
- @m.set @key3, @value
134
- @m.set @key1, @value
135
- @m.set @key2, @value
136
- @m.set @key3, @value
123
+
124
+ # restart_servers
125
+
126
+
127
+ if defined? Memcached
128
+ @m = Memcached.new(
129
+ @opts[0],
130
+ @opts[1].merge(:no_block => true, :buffer_requests => true)
131
+ )
132
+ x.report("set:ruby:noblock:memcached") do
133
+ n.times do
134
+ @m.set @key1, @value
135
+ @m.set @key2, @value
136
+ @m.set @key3, @value
137
+ @m.set @key1, @value
138
+ @m.set @key2, @value
139
+ @m.set @key3, @value
140
+ end
141
+ end
142
+ @m = Memcached.new(*@opts)
143
+ x.report("set:ruby:memcached") do
144
+ n.times do
145
+ @m.set @key1, @value
146
+ @m.set @key2, @value
147
+ @m.set @key3, @value
148
+ @m.set @key1, @value
149
+ @m.set @key2, @value
150
+ @m.set @key3, @value
151
+ end
152
+ end # if false
137
153
  end
138
- end
139
- end
140
- if defined? MemCache
141
- @m = MemCache.new(*@opts)
142
- x.report("set:ruby:memcache-client") do
143
- n.times do
144
- @m.set @key1, @value
145
- @m.set @key2, @value
146
- @m.set @key3, @value
147
- @m.set @key1, @value
148
- @m.set @key2, @value
149
- @m.set @key3, @value
154
+ if defined? Caffeine
155
+ @m = Caffeine::MemCache.new(@opts[1]); @m.servers = @opts[0]
156
+ x.report("set:ruby:caffeine") do
157
+ n.times do
158
+ @m.set @key1, @value
159
+ @m.set @key2, @value
160
+ @m.set @key3, @value
161
+ @m.set @key1, @value
162
+ @m.set @key2, @value
163
+ @m.set @key3, @value
164
+ end
165
+ end
150
166
  end
151
- end
152
- end
153
-
154
- if defined? Memcached
155
- @m = Memcached.new(*@opts)
156
- x.report("get:plain:memcached") do
157
- n.times do
158
- @m.get @key1, false
159
- @m.get @key2, false
160
- @m.get @key3, false
161
- @m.get @key1, false
162
- @m.get @key2, false
163
- @m.get @key3, false
167
+ if defined? MemCache
168
+ @m = MemCache.new(*@opts)
169
+ x.report("set:ruby:memcache-client") do
170
+ n.times do
171
+ @m.set @key1, @value
172
+ @m.set @key2, @value
173
+ @m.set @key3, @value
174
+ @m.set @key1, @value
175
+ @m.set @key2, @value
176
+ @m.set @key3, @value
177
+ end
178
+ end
164
179
  end
165
- end
166
- end
167
- # Not supported by Caffeine
168
- if defined? MemCache
169
- @m = MemCache.new(*@opts)
170
- x.report("get:plain:memcache-client") do
171
- n.times do
172
- @m.get @key1, true
173
- @m.get @key2, true
174
- @m.get @key3, true
175
- @m.get @key1, true
176
- @m.get @key2, true
177
- @m.get @key3, true
180
+
181
+ if defined? Memcached
182
+ @m = Memcached.new(*@opts)
183
+ x.report("get:plain:memcached") do
184
+ n.times do
185
+ @m.get @key1, false
186
+ @m.get @key2, false
187
+ @m.get @key3, false
188
+ @m.get @key1, false
189
+ @m.get @key2, false
190
+ @m.get @key3, false
191
+ end
192
+ end
178
193
  end
179
- end
180
- end
181
-
182
- if defined? Memcached
183
- @m = Memcached.new(*@opts)
184
- x.report("get:ruby:memcached") do
185
- n.times do
186
- @m.get @key1
187
- @m.get @key2
188
- @m.get @key3
189
- @m.get @key1
190
- @m.get @key2
191
- @m.get @key3
194
+ # Not supported by Caffeine
195
+ if defined? MemCache
196
+ @m = MemCache.new(*@opts)
197
+ x.report("get:plain:memcache-client") do
198
+ n.times do
199
+ @m.get @key1, true
200
+ @m.get @key2, true
201
+ @m.get @key3, true
202
+ @m.get @key1, true
203
+ @m.get @key2, true
204
+ @m.get @key3, true
205
+ end
206
+ end
192
207
  end
193
- end
194
- end
195
- if defined? Caffeine
196
- @m = Caffeine::MemCache.new(@opts[1]); @m.servers = @opts[0]
197
- x.report("get:ruby:caffeine") do
198
- n.times do
199
- @m.get @key1
200
- @m.get @key2
201
- @m.get @key3
202
- @m.get @key1
203
- @m.get @key2
204
- @m.get @key3
208
+
209
+ if defined? Memcached
210
+ @m = Memcached.new(*@opts)
211
+ x.report("get:ruby:memcached") do
212
+ n.times do
213
+ @m.get @key1
214
+ @m.get @key2
215
+ @m.get @key3
216
+ @m.get @key1
217
+ @m.get @key2
218
+ @m.get @key3
219
+ end
220
+ end
205
221
  end
206
- end
207
- end
208
- if defined? MemCache
209
- @m = MemCache.new(*@opts)
210
- x.report("get:ruby:memcache-client") do
211
- n.times do
212
- @m.get @key1
213
- @m.get @key2
214
- @m.get @key3
215
- @m.get @key1
216
- @m.get @key2
217
- @m.get @key3
222
+ if defined? Caffeine
223
+ @m = Caffeine::MemCache.new(@opts[1]); @m.servers = @opts[0]
224
+ x.report("get:ruby:caffeine") do
225
+ n.times do
226
+ @m.get @key1
227
+ @m.get @key2
228
+ @m.get @key3
229
+ @m.get @key1
230
+ @m.get @key2
231
+ @m.get @key3
232
+ end
233
+ end
218
234
  end
219
- end
220
- end
221
-
222
- # restart_servers
223
-
224
- if defined? Memcached
225
- @m = Memcached.new(*@opts)
226
- x.report("missing:ruby:memcached") do
227
- n.times do
228
- begin @m.delete @key1; rescue Memcached::NotFound; end
229
- begin @m.get @key1; rescue Memcached::NotFound; end
230
- begin @m.delete @key2; rescue Memcached::NotFound; end
231
- begin @m.get @key2; rescue Memcached::NotFound; end
232
- begin @m.delete @key3; rescue Memcached::NotFound; end
233
- begin @m.get @key3; rescue Memcached::NotFound; end
235
+ if defined? MemCache
236
+ @m = MemCache.new(*@opts)
237
+ x.report("get:ruby:memcache-client") do
238
+ n.times do
239
+ @m.get @key1
240
+ @m.get @key2
241
+ @m.get @key3
242
+ @m.get @key1
243
+ @m.get @key2
244
+ @m.get @key3
245
+ end
246
+ end
234
247
  end
235
- end
236
- end
237
- if defined? Caffeine
238
- @m = Caffeine::MemCache.new(@opts[1]); @m.servers = @opts[0]
239
- x.report("missing:ruby:caffeine") do
240
- n.times do
241
- begin @m.delete @key1; rescue; end
242
- begin @m.get @key1; rescue; end
243
- begin @m.delete @key2; rescue; end
244
- begin @m.get @key2; rescue; end
245
- begin @m.delete @key3; rescue; end
246
- begin @m.get @key3; rescue; end
248
+
249
+ # restart_servers
250
+
251
+ if defined? Memcached
252
+ @m = Memcached.new(*@opts)
253
+ x.report("missing:ruby:memcached") do
254
+ n.times do
255
+ begin @m.delete @key1; rescue Memcached::NotFound; end
256
+ begin @m.get @key1; rescue Memcached::NotFound; end
257
+ begin @m.delete @key2; rescue Memcached::NotFound; end
258
+ begin @m.get @key2; rescue Memcached::NotFound; end
259
+ begin @m.delete @key3; rescue Memcached::NotFound; end
260
+ begin @m.get @key3; rescue Memcached::NotFound; end
261
+ end
262
+ end
247
263
  end
248
- end
249
- end
250
- if defined? MemCache
251
- @m = MemCache.new(*@opts)
252
- x.report("missing:ruby:memcache-client") do
253
- n.times do
254
- begin @m.delete @key1; rescue; end
255
- begin @m.get @key1; rescue; end
256
- begin @m.delete @key2; rescue; end
257
- begin @m.get @key2; rescue; end
258
- begin @m.delete @key3; rescue; end
259
- begin @m.get @key3; rescue; end
264
+ if defined? Memcached
265
+ @m = Memcached.new(*@opts)
266
+ x.report("missing:ruby:memcached:inline") do
267
+ n.times do
268
+ @m.delete @key1 rescue nil
269
+ @m.get @key1 rescue nil
270
+ @m.delete @key2 rescue nil
271
+ @m.get @key2 rescue nil
272
+ @m.delete @key3 rescue nil
273
+ @m.get @key3 rescue nil
274
+ end
275
+ end
260
276
  end
261
- end
262
- end
263
-
264
- # restart_servers
265
-
266
- if defined? Memcached
267
- @m = Memcached.new(
268
- @opts[0],
269
- @opts[1].merge(:no_block => true, :buffer_requests => true)
270
- )
271
- x.report("mixed:ruby:noblock:memcached") do
272
- n.times do
273
- @m.set @key1, @value
274
- @m.set @key2, @value
275
- @m.set @key3, @value
276
- @m.get @key1
277
- @m.get @key2
278
- @m.get @key3
279
- @m.set @key1, @value
280
- @m.get @key1
281
- @m.set @key2, @value
282
- @m.get @key2
283
- @m.set @key3, @value
284
- @m.get @key3
277
+ if defined? Caffeine
278
+ @m = Caffeine::MemCache.new(@opts[1]); @m.servers = @opts[0]
279
+ x.report("missing:ruby:caffeine") do
280
+ n.times do
281
+ begin @m.delete @key1; rescue; end
282
+ begin @m.get @key1; rescue; end
283
+ begin @m.delete @key2; rescue; end
284
+ begin @m.get @key2; rescue; end
285
+ begin @m.delete @key3; rescue; end
286
+ begin @m.get @key3; rescue; end
287
+ end
288
+ end
285
289
  end
286
- end
287
- @m = Memcached.new(*@opts)
288
- x.report("mixed:ruby:memcached") do
289
- n.times do
290
- @m.set @key1, @value
291
- @m.set @key2, @value
292
- @m.set @key3, @value
293
- @m.get @key1
294
- @m.get @key2
295
- @m.get @key3
296
- @m.set @key1, @value
297
- @m.get @key1
298
- @m.set @key2, @value
299
- @m.get @key2
300
- @m.set @key3, @value
301
- @m.get @key3
290
+ if defined? MemCache
291
+ @m = MemCache.new(*@opts)
292
+ x.report("missing:ruby:memcache-client") do
293
+ n.times do
294
+ begin @m.delete @key1; rescue; end
295
+ begin @m.get @key1; rescue; end
296
+ begin @m.delete @key2; rescue; end
297
+ begin @m.get @key2; rescue; end
298
+ begin @m.delete @key3; rescue; end
299
+ begin @m.get @key3; rescue; end
300
+ end
301
+ end
302
302
  end
303
- end # if false
304
- end
305
- if defined? Caffeine
306
- @m = Caffeine::MemCache.new(@opts[1]); @m.servers = @opts[0]
307
- x.report("mixed:ruby:caffeine") do
308
- n.times do
309
- @m.set @key1, @value
310
- @m.set @key2, @value
311
- @m.set @key3, @value
312
- @m.get @key1
313
- @m.get @key2
314
- @m.get @key3
315
- @m.set @key1, @value
316
- @m.get @key1
317
- @m.set @key2, @value
318
- @m.get @key2
319
- @m.set @key3, @value
320
- @m.get @key3
303
+
304
+ # restart_servers
305
+
306
+ if defined? Memcached
307
+ @m = Memcached.new(
308
+ @opts[0],
309
+ @opts[1].merge(:no_block => true, :buffer_requests => true)
310
+ )
311
+ x.report("mixed:ruby:noblock:memcached") do
312
+ n.times do
313
+ @m.set @key1, @value
314
+ @m.set @key2, @value
315
+ @m.set @key3, @value
316
+ @m.get @key1
317
+ @m.get @key2
318
+ @m.get @key3
319
+ @m.set @key1, @value
320
+ @m.get @key1
321
+ @m.set @key2, @value
322
+ @m.get @key2
323
+ @m.set @key3, @value
324
+ @m.get @key3
325
+ end
326
+ end
327
+ @m = Memcached.new(*@opts)
328
+ x.report("mixed:ruby:memcached") do
329
+ n.times do
330
+ @m.set @key1, @value
331
+ @m.set @key2, @value
332
+ @m.set @key3, @value
333
+ @m.get @key1
334
+ @m.get @key2
335
+ @m.get @key3
336
+ @m.set @key1, @value
337
+ @m.get @key1
338
+ @m.set @key2, @value
339
+ @m.get @key2
340
+ @m.set @key3, @value
341
+ @m.get @key3
342
+ end
343
+ end # if false
321
344
  end
322
- end
323
- end
324
- if defined? MemCache
325
- @m = MemCache.new(*@opts)
326
- x.report("mixed:ruby:memcache-client") do
327
- n.times do
328
- @m.set @key1, @value
329
- @m.set @key2, @value
330
- @m.set @key3, @value
331
- @m.get @key1
332
- @m.get @key2
333
- @m.get @key3
334
- @m.set @key1, @value
335
- @m.get @key1
336
- @m.set @key2, @value
337
- @m.get @key2
338
- @m.set @key3, @value
339
- @m.get @key3
345
+ if defined? Caffeine
346
+ @m = Caffeine::MemCache.new(@opts[1]); @m.servers = @opts[0]
347
+ x.report("mixed:ruby:caffeine") do
348
+ n.times do
349
+ @m.set @key1, @value
350
+ @m.set @key2, @value
351
+ @m.set @key3, @value
352
+ @m.get @key1
353
+ @m.get @key2
354
+ @m.get @key3
355
+ @m.set @key1, @value
356
+ @m.get @key1
357
+ @m.set @key2, @value
358
+ @m.get @key2
359
+ @m.set @key3, @value
360
+ @m.get @key3
361
+ end
362
+ end
340
363
  end
341
- end
342
- end
343
-
344
- # restart_servers
345
-
346
- if defined? Memcached
347
- unless ARGV.include? "--no-hash"
348
- n = 10000
349
- Memcached::HASH_VALUES.each do |mode,|
350
- @m = Memcached.new(@opts[0], @opts[1].merge(:hash => mode))
351
- x.report("hash:#{mode}:memcached") do
364
+ if defined? MemCache
365
+ @m = MemCache.new(*@opts)
366
+ x.report("mixed:ruby:memcache-client") do
352
367
  n.times do
353
- @m.set @key1, @marshalled, 0, false
354
- @m.get @key1, false
355
- @m.set @key2, @marshalled, 0, false
356
- @m.get @key2, false
357
- @m.set @key3, @marshalled, 0, false
358
- @m.get @key3, false
368
+ @m.set @key1, @value
369
+ @m.set @key2, @value
370
+ @m.set @key3, @value
371
+ @m.get @key1
372
+ @m.get @key2
373
+ @m.get @key3
374
+ @m.set @key1, @value
375
+ @m.get @key1
376
+ @m.set @key2, @value
377
+ @m.get @key2
378
+ @m.set @key3, @value
379
+ @m.get @key3
380
+ end
381
+ end
382
+ end
383
+
384
+ # restart_servers
385
+
386
+ if defined? Memcached
387
+ unless ARGV.include? "--no-hash"
388
+ n = 10000
389
+ Memcached::HASH_VALUES.each do |mode,|
390
+ @m = Memcached.new(@opts[0], @opts[1].merge(:hash => mode))
391
+ x.report("hash:#{mode}:memcached") do
392
+ n.times do
393
+ @m.set @key1, @marshalled, 0, false
394
+ @m.get @key1, false
395
+ @m.set @key2, @marshalled, 0, false
396
+ @m.get @key2, false
397
+ @m.set @key3, @marshalled, 0, false
398
+ @m.get @key3, false
399
+ end
400
+ end
359
401
  end
360
402
  end
403
+
361
404
  end
362
405
  end
363
-
406
+
364
407
  end
365
408
  end
366
409
 
410
+ Bench.new(recursion).run
411
+
367
412
  if Process.respond_to? :memory
368
413
  Process.memory.each do |key, value|
369
414
  puts "#{key}: #{value/1024.0}M"
@@ -75,6 +75,28 @@ class MemcachedTest < Test::Unit::TestCase
75
75
  end
76
76
  end
77
77
 
78
+ def test_initialize_without_not_found_backtraces
79
+ cache = Memcached.new @servers,
80
+ :show_not_found_backtraces => false
81
+ cache.delete key rescue
82
+ begin
83
+ cache.get key
84
+ rescue Memcached::NotFound => e
85
+ assert e.backtrace.empty?
86
+ end
87
+ end
88
+
89
+ def test_initialize_with_not_found_backtraces
90
+ cache = Memcached.new @servers,
91
+ :show_not_found_backtraces => true
92
+ cache.delete key rescue
93
+ begin
94
+ cache.get key
95
+ rescue Memcached::NotFound => e
96
+ assert !e.backtrace.empty?
97
+ end
98
+ end
99
+
78
100
  def test_initialize_sort_hosts
79
101
  # Original
80
102
  cache = Memcached.new(@servers.sort)
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.8"
4
+ version: 0.8.1
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-02-18 00:00:00 -05:00
33
+ date: 2008-02-21 00:00:00 -05:00
34
34
  default_executable:
35
35
  dependencies: []
36
36
 
metadata.gz.sig CHANGED
Binary file