Skip to content
Permalink
Browse files

Use Zlib.crc32 instead of native extension. Prepare for 1.5.0.5 release.

  • Loading branch information...
mperham committed Nov 25, 2008
1 parent 9c291ad commit 9f81841bbb4fc6a3dfe5525a285a045d3da1a589
Showing with 9 additions and 90 deletions.
  1. +5 −0 History.txt
  2. +0 −38 ext/crc32/crc32.c
  3. +0 −5 ext/crc32/extconf.rb
  4. +2 −33 lib/memcache.rb
  5. +2 −3 memcache-client.gemspec
  6. +0 −11 test/test_mem_cache.rb
@@ -1,3 +1,8 @@
= 1.5.0.5

* Remove native C CRC32_ITU_T extension in favor of Zlib's crc32 method.
memcache-client is now pure Ruby again and will work with JRuby and Rubinius.

= 1.5.0.4

* Get test suite working again (packagethief)

This file was deleted.

Oops, something went wrong.

This file was deleted.

Oops, something went wrong.
@@ -4,38 +4,7 @@
require 'thread'
require 'timeout'
require 'rubygems'

class String

##
# Uses the ITU-T polynomial in the CRC32 algorithm.
begin
require 'crc32'
def crc32_ITU_T
CRC32.itu_t(self)
end
rescue LoadError => e
puts "Loading with slow CRC32 ITU-T implementation: #{e.message}"

def crc32_ITU_T
r = 0xFFFFFFFF

each_byte do |i|
r ^= i
8.times do
if (r & 1) != 0 then
r = (r>>1) ^ 0xEDB88320
else
r >>= 1
end
end
end

r ^ 0xFFFFFFFF
end
end

end
require 'zlib'

##
# A Ruby client library for memcached.
@@ -500,7 +469,7 @@ def get_server_for_key(key)
# sketchy for down servers).

def hash_for(key)
(key.crc32_ITU_T >> 16) & 0x7fff
(Zlib.crc32(key) >> 16) & 0x7fff
end

##
@@ -1,15 +1,14 @@
Gem::Specification.new do |s|
s.name = 'memcache-client'
s.version = '1.5.0.4'
s.version = '1.5.0.5'
s.authors = ['Eric Hodel', 'Robert Cottrell', 'Mike Perham']
s.email = 'mperham@gmail.com'
s.homepage = 'http://github.com/fiveruns/memcache-client'
s.summary = 'A Ruby-based memcached client library'
s.description = s.summary
s.extensions << 'ext/crc32/extconf.rb'

s.require_path = 'lib'

s.files = ["README.txt", "License.txt", "History.txt", "Rakefile", "lib/memcache.rb", "lib/memcache_util.rb", "ext/crc32/crc32.c"]
s.files = ["README.txt", "License.txt", "History.txt", "Rakefile", "lib/memcache.rb", "lib/memcache_util.rb"]
s.test_files = ["test/test_mem_cache.rb"]
end
@@ -164,17 +164,6 @@ def test_cache_get_multi_bad_state
assert_match /get my_namespace:key\r\n/, server.socket.written.string
end

def test_crc32_ITU_T
assert_equal 0, ''.crc32_ITU_T
# First value is the fast C version, last value is the pure Ruby version
assert_in [-886631737, 1260851911], 'my_namespace:key'.crc32_ITU_T
assert_in [-224284233, 870540390], 'my_name√space:key'.crc32_ITU_T
end

def assert_in(possible_values, value)
assert possible_values.include?(value), "#{possible_values.inspect} should contain #{value}"
end

def test_initialize
cache = MemCache.new :namespace => 'my_namespace', :readonly => true

0 comments on commit 9f81841

Please sign in to comment.
You can’t perform that action at this time.