开发者

Memcached error in Ruby on Rails

I have the rails application with Jruby. i do the Active record cache by using memcached. i installed memcache-client gem. since i am connecting memcache server to remote host. my memcache config are as follows in my development.rb:

require 'memcache'

memcache_options = {
  :c_threshold => 10_000,
  :compression开发者_如何学Go => true,
  :debug => false,
  :namespace => "#{RAILS_ENV}",
  :readonly => false,
  :urlencode => false,
  :timeout => 60
}

CACHE = MemCache.new memcache_options
CACHE.servers = 'example.org:0000'

config.action_controller.cache_store = CACHE, {}

When I try to access the page, I get the follwiwng error message on my terminal :

MemCache::MemCacheError in ExampleController#index 
Resource temporarily unavailable - 

I did the telnet example.org 1000 . it works fine and type the command 'stats' will give the successful output.

I am using windows vista... i cann't check my firewall config...i guess if firewall blocks i couldn't even do telnet. Is it i have to open my port on my development machine ? or what else the problem i couldn't figure out.


I strongly encourage you to use Dalli.

config.cache_store = :dalli_store, 'cache-1.example.com', 'cache-2.example.com',
{ :namespace => NAME_OF_RAILS_APP, :expires_in => 1.day, :compress => true, :compress_threshold => 64*1024 }

Otherwise, use the :memcached_store option to configure Memcached.

config.action_controller.cache_store = :memcached_store

To debug the error, open a new Rails console

# rails 3
$ rails c

# rails 2
$ ruby script/console

and try to access Rails.cache. See if it works.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜