зеркало из https://github.com/github/memcached.git
Secret found! Disable shared libmemcached building, to force static inclusion in the bundle/so. A great feat of linking.
This commit is contained in:
Родитель
13fc738f2f
Коммит
789719178b
3
README
3
README
|
@ -27,9 +27,6 @@ You need Ruby 1.8.6. Other versions are not guaranteed to work. You also need {m
|
|||
Install the gem:
|
||||
sudo gem install memcached --no-rdoc --no-ri
|
||||
|
||||
Note that on OS X 10.5 you may need to set the architecture explicitly:
|
||||
sudo env ARCHFLAGS="-arch i386" gem install memcached --no-rdoc --no-ri
|
||||
|
||||
== Usage
|
||||
|
||||
Start a local networked memcached server:
|
||||
|
|
|
@ -5,7 +5,7 @@ HERE = File.expand_path(File.dirname(__FILE__))
|
|||
BUNDLE = Dir.glob("libmemcached-*.tar.gz").first
|
||||
BUNDLE_PATH = BUNDLE.sub(".tar.gz", "")
|
||||
|
||||
$LIBS << " -lmemcached"
|
||||
DARWIN = `uname -sp` == "Darwin i386\n"
|
||||
|
||||
if !ENV["EXTERNAL_LIB"]
|
||||
$includes = " -I#{HERE}/include"
|
||||
|
@ -13,45 +13,52 @@ if !ENV["EXTERNAL_LIB"]
|
|||
|
||||
$CFLAGS = "#{$includes} #{$libraries} #{$CFLAGS}"
|
||||
$LDFLAGS = "#{$libraries} #{$LDFLAGS}"
|
||||
$CPPFLAGS = ""
|
||||
$CPPFLAGS = $ARCH_FLAG = $DLDFLAGS = ""
|
||||
|
||||
$LIBPATH = ["#{HERE}/lib"]
|
||||
$DEFLIBPATH = []
|
||||
|
||||
Dir.chdir(HERE) do
|
||||
if File.exist?("lib")
|
||||
puts "Libmemcached already built; run 'rake clean' first if you need to rebuild."
|
||||
else
|
||||
else
|
||||
puts "Building libmemcached."
|
||||
puts(cmd = "tar xzf #{BUNDLE} 2>&1")
|
||||
raise "'#{cmd}' failed" unless system(cmd)
|
||||
raise "'#{cmd}' failed" unless system(cmd)
|
||||
|
||||
Dir.chdir(BUNDLE_PATH) do
|
||||
puts(cmd = "./configure --prefix=#{HERE} 2>&1")
|
||||
raise "'#{cmd}' failed" unless system(cmd)
|
||||
puts(cmd = "make 2>&1")
|
||||
puts(cmd = "env CFLAGS=-fPIC LDFLAGS=-fPIC ./configure --prefix=#{HERE} --disable-shared --disable-utils 2>&1")
|
||||
raise "'#{cmd}' failed" unless system(cmd)
|
||||
puts(cmd = "make install 2>&1")
|
||||
puts(cmd = "make || true 2>&1")
|
||||
raise "'#{cmd}' failed" unless system(cmd)
|
||||
end
|
||||
puts(cmd = "make install || true 2>&1")
|
||||
raise "'#{cmd}' failed" unless system(cmd)
|
||||
end
|
||||
system("rm -rf #{BUNDLE_PATH}")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
find_header('libmemcached/memcached.h', "#{HERE}/include") or raise
|
||||
# Absolutely prevent the linker from picking up any other libmemcached
|
||||
Dir.chdir("#{HERE}/lib") do
|
||||
system("cp libmemcached.a libmemcached_gem.a")
|
||||
system("cp libmemcached.la libmemcached_gem.la")
|
||||
end
|
||||
$LIBS << " -lmemcached_gem"
|
||||
end
|
||||
|
||||
if ENV['SWIG']
|
||||
puts "Running SWIG."
|
||||
puts(cmd = "swig #{$includes} -ruby -autorename rlibmemcached.i")
|
||||
raise "'#{cmd}' failed" unless system(cmd)
|
||||
end
|
||||
|
||||
if `uname -sp` == "Darwin i386\n"
|
||||
if DARWIN
|
||||
$CFLAGS.gsub! /-arch \S+/, ''
|
||||
$CFLAGS << " -arch i386"
|
||||
$LDFLAGS.gsub! /-arch \S+/, ''
|
||||
$LDFLAGS << " -arch i386"
|
||||
end
|
||||
|
||||
if ENV['SWIG']
|
||||
puts "Running SWIG."
|
||||
puts(cmd = "swig #{$includes} -ruby -autorename rlibmemcached.i")
|
||||
raise "'#{cmd}' failed" unless system(cmd)
|
||||
end
|
||||
|
||||
$CFLAGS.gsub! /-O\d/, ''
|
||||
|
||||
if ENV['DEBUG']
|
||||
|
|
|
@ -22,7 +22,7 @@ class Memcached
|
|||
Lib = Rlibmemcached
|
||||
REQUIRED_VERSION = File.read("#{File.dirname(__FILE__)}/../COMPATIBILITY")[/:: ([\d\.]+)/, 1]
|
||||
RECEIVED_VERSION = Lib.memcached_lib_version
|
||||
raise "libmemcached #{REQUIRED_VERSION} required; your gem is linked to #{RECEIVED_VERSION}." unless REQUIRED_VERSION == RECEIVED_VERSION
|
||||
raise "libmemcached #{REQUIRED_VERSION} required; you somehow linked to #{RECEIVED_VERSION}." unless REQUIRED_VERSION == RECEIVED_VERSION
|
||||
end
|
||||
|
||||
require 'memcached/integer'
|
||||
|
|
|
@ -867,9 +867,13 @@ class MemcachedTest < Test::Unit::TestCase
|
|||
cache.set(key2, @value)
|
||||
end
|
||||
end
|
||||
|
||||
def test_missing_server_with_random_distribution
|
||||
cache = Memcached.new(@servers, :distribution => :random)
|
||||
# FIXME Needs to exercise the ejection code
|
||||
end
|
||||
|
||||
def test_consistent_hashing
|
||||
|
||||
keys = %w(EN6qtgMW n6Oz2W4I ss4A8Brr QShqFLZt Y3hgP9bs CokDD4OD Nd3iTSE1 24vBV4AU H9XBUQs5 E5j8vUq1 AzSh8fva PYBlK2Pi Ke3TgZ4I AyAIYanO oxj8Xhyd eBFnE6Bt yZyTikWQ pwGoU7Pw 2UNDkKRN qMJzkgo2 keFXbQXq pBl2QnIg ApRl3mWY wmalTJW1 TLueug8M wPQL4Qfg uACwus23 nmOk9R6w lwgZJrzJ v1UJtKdG RK629Cra U2UXFRqr d9OQLNl8 KAm1K3m5 Z13gKZ1v tNVai1nT LhpVXuVx pRib1Itj I1oLUob7 Z1nUsd5Q ZOwHehUa aXpFX29U ZsnqxlGz ivQRjOdb mB3iBEAj)
|
||||
|
||||
# Five servers
|
||||
|
|
Загрузка…
Ссылка в новой задаче