memcached 0.16 → 0.16.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/CHANGELOG CHANGED
@@ -1,4 +1,6 @@
1
1
 
2
+ v0.16.1. Use seeded random. Fix realloc bug on Linux.
3
+
2
4
  v0.16. Build properly on OS X Snow Leopard.
3
5
 
4
6
  v0.15.3. UDP fix. 0-value fix. Enforce server_add response code. Better tests.
@@ -7,12 +7,12 @@ BUNDLE_PATH = BUNDLE.sub(".tar.gz", "")
7
7
  DARWIN = `uname -sp` == "Darwin i386\n"
8
8
 
9
9
  # is there a better way to do this?
10
- if ENV['ARCHFLAGS']
11
- archflags = ENV['ARCHFLAGS']
10
+ archflags = if ENV['ARCHFLAGS']
11
+ ENV['ARCHFLAGS']
12
12
  elsif Config::CONFIG['host_os'] == 'darwin10.0'
13
- archflags = "-arch i386 -arch x86_64"
13
+ "-arch i386 -arch x86_64"
14
14
  elsif Config::CONFIG['host_os'] =~ /darwin/
15
- archflags = "-arch i386 -arch ppc"
15
+ "-arch i386 -arch ppc"
16
16
  else
17
17
  archflags = ''
18
18
  end
@@ -58,7 +58,7 @@ if !ENV["EXTERNAL_LIB"]
58
58
  puts(cmd = "make install || true 2>&1")
59
59
  raise "'#{cmd}' failed" unless system(cmd)
60
60
  end
61
- system("rm -rf #{BUNDLE_PATH}")
61
+ system("rm -rf #{BUNDLE_PATH}") unless ENV['DEV']
62
62
  end
63
63
  end
64
64
 
Binary file
@@ -2,12 +2,12 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{memcached}
5
- s.version = "0.16"
5
+ s.version = "0.16.1"
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{2009-08-30}
10
+ s.date = %q{2009-09-02}
11
11
  s.description = %q{An interface to the libmemcached C client.}
12
12
  s.email = %q{}
13
13
  s.extensions = ["ext/extconf.rb"]
@@ -4,25 +4,21 @@ $LOAD_PATH << "#{HERE}/../../lib/"
4
4
  UNIX_SOCKET_NAME = File.join(ENV['TMPDIR']||'/tmp','memcached')
5
5
 
6
6
  require 'memcached'
7
-
8
7
  require 'benchmark'
9
8
  require 'rubygems'
9
+ require 'ruby-debug' if ENV['DEBUG']
10
+ begin; require 'memory'; rescue LoadError; end
10
11
 
11
- begin
12
- require 'memory'
13
- rescue LoadError
14
- end
12
+ ARGV << "--with-memcached" << "--with-memcache-client" if ARGV.join !~ /--with/
15
13
 
16
- if ARGV.join !~ /--with/
17
- ARGV << "--with-memcached" << "--with-memcache-client" << "--with-caffeine"
18
- end
19
-
20
- ARGV.grep(/--with-(\w+)/) do
14
+ ARGV.each do |flag|
15
+ require_name = flag[/--with-(\w+)/, 1]
16
+ gem_name = flag[/--with-(.*)$/, 1]
21
17
  begin
22
- puts "Loading #{$1}"
23
- require $1
18
+ require require_name
19
+ gem gem_name
20
+ puts "Loaded #{$1} #{Gem.loaded_specs[gem_name].version.to_s rescue nil}"
24
21
  rescue LoadError
25
- puts "Failed"
26
22
  end
27
23
  end
28
24
 
@@ -42,19 +38,11 @@ class Bench
42
38
 
43
39
  @opts_networked = [
44
40
  ['127.0.0.1:43042', '127.0.0.1:43043'],
45
- {
46
- :buffer_requests => false,
47
- :no_block => false,
48
- :namespace => "namespace"
49
- }
41
+ {:buffer_requests => false, :no_block => false, :namespace => "namespace"}
50
42
  ]
51
43
  @opt_unix = [
52
44
  ["#{UNIX_SOCKET_NAME}0","#{UNIX_SOCKET_NAME}1"],
53
- {
54
- :buffer_requests => false,
55
- :no_block => false,
56
- :namespace => "namespace"
57
- }
45
+ {:buffer_requests => false, :no_block => false, :namespace => "namespace"}
58
46
  ]
59
47
  @key1 = "Short"
60
48
  @key2 = "Sym1-2-3::45"*8
@@ -64,28 +52,16 @@ class Bench
64
52
  @key5 = "Medium2"*8
65
53
  @key6 = "Long3"*40
66
54
 
67
- restart_servers
55
+ system("ruby #{HERE}/../setup.rb")
56
+ sleep(1)
68
57
  end
69
58
 
70
59
  def run(level = @recursion)
71
- if level > 0
72
- run_inner(level - 1)
73
- else
74
- benchmark
75
- end
76
- end
77
-
78
- def run_inner(level)
79
- run(level)
60
+ level > 0 ? run(level - 1) : benchmark
80
61
  end
81
62
 
82
63
  private
83
64
 
84
- def restart_servers
85
- system("ruby #{HERE}/../setup.rb")
86
- sleep(1)
87
- end
88
-
89
65
  def benchmark
90
66
  Benchmark.bm(35) do |x|
91
67
 
@@ -143,7 +119,6 @@ class Bench
143
119
  end
144
120
  end
145
121
  end
146
- # Not supported by Caffeine
147
122
  if defined? MemCache
148
123
  @m = MemCache.new(*@opts_networked)
149
124
  x.report("set:plain:memcache-client") do
@@ -158,9 +133,6 @@ class Bench
158
133
  end
159
134
  end
160
135
 
161
- # restart_servers
162
-
163
-
164
136
  if defined? Memcached
165
137
  @m = Memcached.new(
166
138
  @opts_networked[0],
@@ -213,19 +185,6 @@ class Bench
213
185
  end
214
186
  end
215
187
  end
216
- if defined? Caffeine
217
- @m = Caffeine::MemCache.new(@opts_networked[1]); @m.servers = @opts_networked[0]
218
- x.report("set:ruby:caffeine") do
219
- n.times do
220
- @m.set @key1, @value
221
- @m.set @key2, @value
222
- @m.set @key3, @value
223
- @m.set @key1, @value
224
- @m.set @key2, @value
225
- @m.set @key3, @value
226
- end
227
- end
228
- end
229
188
  if defined? MemCache
230
189
  @m = MemCache.new(*@opts_networked)
231
190
  x.report("set:ruby:memcache-client") do
@@ -264,7 +223,6 @@ class Bench
264
223
  end
265
224
  end
266
225
  end
267
- # Not supported by Caffeine
268
226
  if defined? MemCache
269
227
  @m = MemCache.new(*@opts_networked)
270
228
  x.report("get:plain:memcache-client") do
@@ -303,19 +261,6 @@ class Bench
303
261
  end
304
262
  end
305
263
  end
306
- if defined? Caffeine
307
- @m = Caffeine::MemCache.new(@opts_networked[1]); @m.servers = @opts_networked[0]
308
- x.report("get:ruby:caffeine") do
309
- n.times do
310
- @m.get @key1
311
- @m.get @key2
312
- @m.get @key3
313
- @m.get @key1
314
- @m.get @key2
315
- @m.get @key3
316
- end
317
- end
318
- end
319
264
  if defined? MemCache
320
265
  @m = MemCache.new(*@opts_networked)
321
266
  x.report("get:ruby:memcache-client") do
@@ -352,15 +297,6 @@ class Bench
352
297
  end
353
298
  end
354
299
  end
355
- if defined? Caffeine
356
- @m = Caffeine::MemCache.new(@opts_networked[1]); @m.servers = @opts_networked[0]
357
- x.report("multiget:ruby:caffeine") do
358
- n.times do
359
- # We don't use the keys array because splat is slow
360
- @m.get @key1, @key2, @key3, @key4, @key5, @key6
361
- end
362
- end
363
- end
364
300
  if defined? MemCache
365
301
  @m = MemCache.new(*@opts_networked)
366
302
  x.report("multiget:ruby:memcache-client") do
@@ -371,8 +307,6 @@ class Bench
371
307
  end
372
308
  end
373
309
 
374
- # restart_servers
375
-
376
310
  if defined? Memcached
377
311
  @m = Memcached.new(*@opts_networked)
378
312
  x.report("missing:ruby:memcached:net") do
@@ -421,19 +355,6 @@ class Bench
421
355
  end
422
356
  end
423
357
  end
424
- if defined? Caffeine
425
- @m = Caffeine::MemCache.new(@opts_networked[1]); @m.servers = @opts_networked[0]
426
- x.report("missing:ruby:caffeine") do
427
- n.times do
428
- begin @m.delete @key1; rescue; end
429
- begin @m.get @key1; rescue; end
430
- begin @m.delete @key2; rescue; end
431
- begin @m.get @key2; rescue; end
432
- begin @m.delete @key3; rescue; end
433
- begin @m.get @key3; rescue; end
434
- end
435
- end
436
- end
437
358
  if defined? MemCache
438
359
  @m = MemCache.new(*@opts_networked)
439
360
  x.report("missing:ruby:memcache-client") do
@@ -448,8 +369,6 @@ class Bench
448
369
  end
449
370
  end
450
371
 
451
- # restart_servers
452
-
453
372
  if defined? Memcached
454
373
  @m = Memcached.new(
455
374
  @opts_networked[0],
@@ -526,25 +445,6 @@ class Bench
526
445
  end
527
446
  end # if false
528
447
  end
529
- if defined? Caffeine
530
- @m = Caffeine::MemCache.new(@opts_networked[1]); @m.servers = @opts_networked[0]
531
- x.report("mixed:ruby:caffeine") do
532
- n.times do
533
- @m.set @key1, @value
534
- @m.set @key2, @value
535
- @m.set @key3, @value
536
- @m.get @key1
537
- @m.get @key2
538
- @m.get @key3
539
- @m.set @key1, @value
540
- @m.get @key1
541
- @m.set @key2, @value
542
- @m.get @key2
543
- @m.set @key3, @value
544
- @m.get @key3
545
- end
546
- end
547
- end
548
448
  if defined? MemCache
549
449
  @m = MemCache.new(*@opts_networked)
550
450
  x.report("mixed:ruby:memcache-client") do
@@ -565,8 +465,6 @@ class Bench
565
465
  end
566
466
  end
567
467
 
568
- # restart_servers
569
-
570
468
  if defined? Memcached
571
469
  unless ARGV.include? "--no-hash"
572
470
  Memcached::HASH_VALUES.each do |mode, int|
@@ -381,20 +381,22 @@ class MemcachedTest < Test::Unit::TestCase
381
381
  @cache.get(["#{key}_1", "#{key}_2"])
382
382
  end
383
383
  end
384
-
385
- def test_get_with_random_distribution
384
+
385
+ def test_random_distribution_is_statistically_random
386
386
  cache = Memcached.new(@servers, :distribution => :random)
387
- cache.set key, @value
387
+ cache.flush
388
+ 20.times { |i| cache.set "#{key}#{i}", @value }
388
389
 
389
- hits = (0..10).to_a.map do
390
+ cache, hits = Memcached.new(@servers.first), 0
391
+ 20.times do |i|
390
392
  begin
391
- cache.get(key)
393
+ cache.get "#{key}#{i}"
394
+ hits += 1
392
395
  rescue Memcached::NotFound
393
396
  end
394
- end.compact.size
397
+ end
395
398
 
396
- assert 0 < hits
397
- assert 10 > hits
399
+ assert_not_equal 4, hits
398
400
  end
399
401
 
400
402
  # Set
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.16"
4
+ version: 0.16.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: 2009-08-30 00:00:00 -07:00
33
+ date: 2009-09-02 00:00:00 -07:00
34
34
  default_executable:
35
35
  dependencies: []
36
36
 
metadata.gz.sig CHANGED
Binary file