Sha256: 3fa37920ac07ff85822aa903db1c82e4061acd2b796b8f258e9da32054b0c4dc

Contents?: true

Size: 637 Bytes

Versions: 2

Compression:

Stored size: 637 Bytes

Contents

module Resque
  module Plugins
    module History

      MAX_HISTORY_SIZE = 500
      HISTORY_SET_NAME = "resque_history"

      def maximum_history_size
        @max_hisory ||=MAX_HISTORY_SIZE
      end

      def after_perform_history(*args)
        Resque.redis.rpush(HISTORY_SET_NAME, {"class"=>"#{self}",
                                              "args"=>args,
                                              "time"=>Time.now.strftime("%Y-%m-%d %H:%M")
        }.to_json)

        if Resque.redis.llen(HISTORY_SET_NAME) > maximum_history_size
          Resque.redis.lpop(HISTORY_SET_NAME)
        end

      end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
resque-history-1.6.0 lib/resque-history/plugins/history.rb
resque-history-1.5.0 lib/resque-history/plugins/history.rb