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 +0 -0
- data/BENCHMARKS +29 -29
- data/CHANGELOG +2 -0
- data/lib/memcached/exceptions.rb +21 -9
- data/lib/memcached/memcached.rb +16 -2
- data/memcached.gemspec +3 -3
- data/test/profile/benchmark.rb +355 -310
- data/test/unit/memcached_test.rb +22 -0
- metadata +2 -2
- metadata.gz.sig +0 -0
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.
|
14
|
-
set:plain:memcached 0.
|
15
|
-
set:plain:memcache-client
|
16
|
-
set:ruby:noblock:memcached 0.190000 0.
|
17
|
-
set:ruby:memcached 0.
|
18
|
-
set:ruby:caffeine 5.
|
19
|
-
set:ruby:memcache-client
|
20
|
-
get:plain:memcached 0.
|
21
|
-
get:plain:memcache-client
|
22
|
-
get:ruby:memcached 0.
|
23
|
-
get:ruby:caffeine 5.
|
24
|
-
get:ruby:memcache-client
|
25
|
-
missing:ruby:memcached 0.
|
26
|
-
missing:ruby:
|
27
|
-
missing:ruby:
|
28
|
-
|
29
|
-
mixed:ruby:memcached
|
30
|
-
mixed:ruby:
|
31
|
-
mixed:ruby:
|
32
|
-
|
33
|
-
hash:
|
34
|
-
hash:
|
35
|
-
hash:
|
36
|
-
hash:
|
37
|
-
hash:
|
38
|
-
hash:
|
39
|
-
hash:
|
40
|
-
hash:fnv1a_32:memcached 1.
|
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
data/lib/memcached/exceptions.rb
CHANGED
@@ -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
|
|
data/lib/memcached/memcached.rb
CHANGED
@@ -13,7 +13,8 @@ class Memcached
|
|
13
13
|
:buffer_requests => false,
|
14
14
|
:support_cas => false,
|
15
15
|
:tcp_nodelay => false,
|
16
|
-
:
|
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
|
-
|
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-
|
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"]
|
data/test/profile/benchmark.rb
CHANGED
@@ -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
|
-
|
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
|
-
|
45
|
-
system("ruby #{HERE}/../setup.rb")
|
46
|
-
sleep(1)
|
47
|
-
end
|
30
|
+
class Bench
|
48
31
|
|
49
|
-
|
32
|
+
def initialize(recursion)
|
50
33
|
|
51
|
-
|
52
|
-
|
53
|
-
|
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
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
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
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
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
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
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
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
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
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
@
|
132
|
-
@
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
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
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
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
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
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
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
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
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
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
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
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
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
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
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
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
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
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
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
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
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
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
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
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
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
@
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
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
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
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
|
-
|
342
|
-
|
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, @
|
354
|
-
@m.
|
355
|
-
@m.set @
|
356
|
-
@m.get @
|
357
|
-
@m.
|
358
|
-
@m.get @key3
|
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"
|
data/test/unit/memcached_test.rb
CHANGED
@@ -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:
|
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-
|
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
|