LoginSignup
5
6

More than 5 years have passed since last update.

Resque:Redisをバックエンドとしたタスクキューシステム

Last updated at Posted at 2012-12-26

GitHubで開発,利用されている https://github.com/resque/resque
組込まれているwebビューが見やすく,失敗したタスクのリトライや削除もできるようになっている.
Resqueを使ってTwitterに投稿するのは以下のように書く

# tweet.rb
require 'twitter'
class Tweet
  @queue = :post_to_twitter

  def self.perform(oauth_id, msg)
    oauth = Oauth.find(oauth_id)
    Twitter.configure do |config|
      config.consumer_key       = CONSUMER_KEY
      config.consumer_secret    = CONSUMER_SECRET
      config.oauth_token        = oauth.token
      config.oauth_token_secret = oauth.secret
    end
    twitter_client = Twitter::Client.new
    twitter_client.update(msg)
  end
end

# enqueue
Resque.enqueue(Tweet, oauth_id, msg)
5
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
6