Skip to content

Instantly share code, notes, and snippets.

@tatiC
Created April 19, 2012 17:55
Show Gist options
  • Save tatiC/2422603 to your computer and use it in GitHub Desktop.
Save tatiC/2422603 to your computer and use it in GitHub Desktop.
Usando resque-redis numa applicação Rails
refs: https://github.com/defunkt/resque
Instalar redis
Instalar resque
Gemfile: gem 'resque', 'versão', :require => 'resque/server'
Criar arquivo:
lib/tasks/resque.rake
require "resque/tasks"
task "resque:setup" => :environment
--------------------------------------
No arquivo application.rb:
config.autoload_paths += %W(
#{config.root}/lib/tasks)
--------------------------------------
Criar app/workers/nome_arquivo.rb
class NomeArquivo
@queue = :nome_queue
def self.perform(objeto_id)
-------
end
end
--------------------------------------
No controller
Resque.enqueue(NomeArquivo, objeto.id)
Inicia servidor-redis:(port 6379)
alias redis="cd ~/Dropbox/work/projects/resque;redis-server"
Para visualizar filas:(port: 5678)
alias filas="resque-web"
Inicia worker:
rake resque:work QUEUE=nome_queue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment