module Sidetiq::Schedulable::ClassMethods

Attributes

schedule[W]

Public Instance Methods

last_scheduled_occurrence() click to toggle source

Public: Returns a Float timestamp of the last scheduled run.

# File lib/sidetiq/schedulable.rb, line 22
def last_scheduled_occurrence
  get_timestamp "last"
end
next_scheduled_occurrence() click to toggle source

Public: Returns a Float timestamp of the next scheduled run.

# File lib/sidetiq/schedulable.rb, line 32
def next_scheduled_occurrence
  get_timestamp "next"
end
schedule() click to toggle source

Public: Returns the Sidetiq::Schedule for this worker.

# File lib/sidetiq/schedulable.rb, line 27
def schedule
  @schedule ||= Sidetiq::Schedule.new
end
schedule_description() click to toggle source
# File lib/sidetiq/schedulable.rb, line 36
def schedule_description
  get_schedulable_key("schedule_description")
end

Private Instance Methods

get_schedulable_key(key) click to toggle source
# File lib/sidetiq/schedulable.rb, line 62
def get_schedulable_key(key)
  Sidekiq.redis_pool.with { |r| r.get("sidetiq:#{name}:#{key}") }
end
get_schedulable_keys() click to toggle source
# File lib/sidetiq/schedulable.rb, line 58
def get_schedulable_keys
  %w(next last schedule_description history).map { |key| "sidetiq:#{name}:#{key}" }
end
get_timestamp(key) click to toggle source
# File lib/sidetiq/schedulable.rb, line 70
def get_timestamp(key)
  (get_schedulable_key(key) || -1).to_f
end
set_schedulable_key(key, value) click to toggle source
# File lib/sidetiq/schedulable.rb, line 66
def set_schedulable_key(key, value)
  Sidekiq.redis_pool.with { |r| r.set("sidetiq:#{name}:#{key}", value) }
end