Sha256: b95d7ab81daf7e8b85ea79210796572df573453d2a67c687c16212765c29c518

Contents?: true

Size: 845 Bytes

Versions: 3

Compression:

Stored size: 845 Bytes

Contents

module Resque
  module Failure
    # A Failure backend that stores exceptions in Redis. Very simple but
    # works out of the box, along with support in the Resque web app.
    class Redis < Base
      def save
        data = {
          :failed_at => Time.now.strftime("%Y/%m/%d %H:%M:%S"),
          :payload   => payload,
          :error     => exception.to_s,
          :backtrace => exception.backtrace,
          :worker    => worker.to_s,
          :queue     => queue
        }
        data = Resque.encode(data)
        Resque.redis.rpush(:failed, data)
      end

      def self.count
        Resque.redis.llen(:failed).to_i
      end

      def self.all(start = 0, count = 1)
        Resque.list_range(:failed, start, count)
      end
      
      def self.clear
        Resque.redis.del(:failed)
      end
      
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
resque-1.6.0 lib/resque/failure/redis.rb
resque-1.5.2 lib/resque/failure/redis.rb
resque-1.5.1 lib/resque/failure/redis.rb