Possibile bug in cache_fu

Posted by Dibi Store Tue, 20 Nov 2007 11:54:00 GMT

Se ottenete questo errore quando usate rake per avviare memcached:

undefined method `[]' for nil:NilClass

Sinifica che avete una versione buggata del plugin cache_fu. In sostanza per farla vreve andate sulla directory del plugin, poi su task e aprite il memcached rake e sostituitelo con questo:

namespace :memcached do
  desc "Start memcached locally" 
  task :start do
    memcached config_args
  end

  desc "Restart memcached locally" 
  task :restart do
    Rake::Task['memcached:stop'].invoke
    Rake::Task['memcached:start'].invoke
  end

  desc "Stop memcached locally" 
  task :stop do
    `killall memcached`
  end
end

def config
  return @config if @config
  config  = YAML.load_file(RAILS_ROOT + '/config/memcached.yml') 
  @config = config['defaults'].merge(config['development'])
end

def config_args
  config
  args = {
    '-p' => Array(@config['servers']).first.split(':').last,
    '-c' => @config['c_threshold'],
    '-m' => @config['memory'],
    '-d' => ''
  }

  args.to_a * ' '
end

def memcached(*args)
  `/usr/bin/env memcached #{args * ' '}`
end

In pratica non venivano richiamati gli argomenti (qui l'errore che avete ricevuto) perchè non veniva richiamato il metodo args, in piu il percorso relativo al file di configurazione era sbagliato, meglio metterlo con RAILS_ROOT.

Mi stupisco ancora che non venga fissato in quanto cosi è inutilizzabile.

Enjoy

Posted in  | Tags  | no comments

Comments

(leave url/email »)

   Preview comment