Class: SuperPoller::StarlingQueue

Inherits:
Object
  • Object
show all
Defined in:
lib/super_poller/starling_queue.rb

Instance Method Summary collapse

Constructor Details

#initialize(queue_name, *args) ⇒ StarlingQueue

Returns a new instance of StarlingQueue.



4
5
6
7
# File 'lib/super_poller/starling_queue.rb', line 4

def initialize(queue_name, *args)
  @queue_name = queue_name.to_s
  @queue = Starling.new(*args)
end

Instance Method Details

#any?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/super_poller/starling_queue.rb', line 29

def any?
  !empty?
end

#empty?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/super_poller/starling_queue.rb', line 25

def empty?
  length.zero?
end

#fetchObject



17
18
19
# File 'lib/super_poller/starling_queue.rb', line 17

def fetch
  @queue.fetch(@queue_name)
end

#flushObject



33
34
35
36
37
38
39
40
41
42
# File 'lib/super_poller/starling_queue.rb', line 33

def flush
  @queue.delete(@queue_name)
rescue MemCache::MemCacheError => e
  if e.message =~ /bad command line format/
    STDERR.puts "WARNING: Server could not handle delete command. Falling back to the MUCH slower, and quite unreliable flush method. Consider using Reevoo Starling (http://github.com/reevoo/starling)"
    @queue.flush(@queue_name)
  else
    raise
  end
end

#lengthObject



21
22
23
# File 'lib/super_poller/starling_queue.rb', line 21

def length
  @queue.sizeof(@queue_name)
end

#popObject



9
10
11
# File 'lib/super_poller/starling_queue.rb', line 9

def pop
  @queue.get(@queue_name)
end

#push(v) ⇒ Object



13
14
15
# File 'lib/super_poller/starling_queue.rb', line 13

def push(v)
  @queue.set(@queue_name, v)
end