Skip to content
dwbutler edited this page Nov 29, 2012 · 5 revisions

Qu supports configurable backends for managing queues. While all of the backends should behave the same, all databases are not created equal, so there may be some quirks unique to each backend. We'll document them here as they become known.

Redis

Redis is a great database for managing a queue. To use it, simply add the qu-redis gem to your Gemfile.

gem 'qu-redis'

By default, everything will be stored in a 'qu' namespace in a local Redis database. You can customize the namespace:

Qu.configure do |c|
  c.backend.namespace = 'myapp:qu'
end

If you want to use a different Redis database, you can simply set the connection:

Qu.configure do |c|
  c.connection = Redis::Namespace.new('myapp:qu',
    :redis => Redis.connect(:url => 'redis://user:[email protected]/0'))
end

MongoDB

MongoDB makes a great queue database with the findAndModify command. To use the MongoDB backend, add the qu-mongo gem to your Gemfile:

  gem 'qu-mongo'

By default, Qu will use the "qu" database in the local MongoDB instance. You can customize it by setting the connection to your database:

Qu.configure do |c|
  c.connection = Mongo::Connection.new('myhost.com', 27017).db("myapp-#{Rails.env}")
end

Mongoid

Mongoid 3.x uses its own mongoDB driver, Moped. To use the Moped driver, use the qu-mongoid gem instead of qu-mongo:

  gem 'qu-mongoid'

Qu-Mongoid will automatically connect to the default session configured in mongoid.yml. If a default session is not configured, it will attempt to read from ENV['MONGOHQ_URL'] and ENV['MONGOLAB_URI'], so it should work on Heroku. If you need to use a different Mongoid session, you can do the following:

Qu.configure do |c|
  c.backend.session = :qu
end
Clone this wiki locally