Monday, February 18, 2013

An error occurred while installing memcached (1.4.6), and Bundler cannot continue


Memcached needs following packages in order to install memcached gem.

Install the dependent packages:

apt-get install libmemcached-dev libsasl2-dev
apt-get install memcached

Now bundle or get it directly:

sudo gem install memcached –no-rdoc –no-ri

Test:

moin@haidar:~/workspace/kloud$ memcached -p 11211 &
[1] 29573
moin@haidar:~/workspace/kloud$ irb
1.9.3p385 :001 > require 'rubygems'
 => false 
1.9.3p385 :002 > require 'memcached'
 => true 
1.9.3p385 :003 >  $cache = Memcached.new("localhost:11211")
 => #, @options={:hash=>:fnv1_32, :no_block=>false, :noreply=>false, :distribution=>:consistent_ketama, :ketama_weighted=>true, :buffer_requests=>false, :cache_lookups=>true, :support_cas=>false, :tcp_nodelay=>false, :show_backtraces=>false, :retry_timeout=>30, :timeout=>0.25, :rcv_timeout=>0.25, :poll_timeout=>0.25, :connect_timeout=>4, :prefix_key=>"", :prefix_delimiter=>"", :hash_with_prefix_key=>true, :default_ttl=>604800, :default_weight=>8, :sort_hosts=>false, :auto_eject_hosts=>true, :server_failure_limit=>2, :verify_key=>true, :use_udp=>false, :binary_protocol=>false, :credentials=>nil, :experimental_features=>false, :exception_retry_limit=>5, :exceptions_to_retry=>[Memcached::ServerIsMarkedDead, Memcached::ATimeoutOccurred, Memcached::ConnectionBindFailure, Memcached::ConnectionFailure, Memcached::ConnectionSocketCreateFailure, Memcached::Failure, Memcached::MemoryAllocationFailure, Memcached::ReadFailure, Memcached::ServerEnd, Memcached::ServerError, Memcached::SystemError, Memcached::UnknownReadFailure, Memcached::WriteFailure, Memcached::SomeErrorsWereReported]}, @default_ttl=604800, @not_found=#, @not_stored=#
1.9.3p385 :004 > target = {:first => 'Moin', :last => 'Haidar'}
 => {:first=>"Moin", :last=>"Haidar"} 
1.9.3p385 :010 > $cache.set 'test', target
 => nil 
1.9.3p385 :011 > $cache.get 'test'
 => {:first=>"Moin", :last=>"Haidar"}

No comments:

Post a Comment