Class: Workerholic::SortedSet

Inherits:
Object
  • Object
show all
Defined in:
lib/workerholic/sorted_set.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name = 'workerholic:scheduled_jobs') ⇒ SortedSet

Returns a new instance of SortedSet.



5
6
7
8
# File 'lib/workerholic/sorted_set.rb', line 5

def initialize(name = 'workerholic:scheduled_jobs')
  @storage = Storage::RedisWrapper.new
  @name = name
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/workerholic/sorted_set.rb', line 3

def name
  @name
end

#storageObject (readonly)

Returns the value of attribute storage.



3
4
5
# File 'lib/workerholic/sorted_set.rb', line 3

def storage
  @storage
end

Instance Method Details

#add(serialized_job, score) ⇒ Object



10
11
12
# File 'lib/workerholic/sorted_set.rb', line 10

def add(serialized_job, score)
  storage.add_to_set(name, score, serialized_job)
end

#empty?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/workerholic/sorted_set.rb', line 22

def empty?
  storage.sorted_set_size(name) == 0
end

#peekObject



18
19
20
# File 'lib/workerholic/sorted_set.rb', line 18

def peek
  storage.peek(name)
end

#remove(score) ⇒ Object



14
15
16
# File 'lib/workerholic/sorted_set.rb', line 14

def remove(score)
  storage.remove_from_set(name, score)
end