Class: SuperPoller::StarlingQueue
- Inherits:
-
Object
- Object
- SuperPoller::StarlingQueue
- Defined in:
- lib/super_poller/starling_queue.rb
Instance Method Summary collapse
- #any? ⇒ Boolean
- #empty? ⇒ Boolean
- #fetch ⇒ Object
- #flush ⇒ Object
-
#initialize(queue_name, *args) ⇒ StarlingQueue
constructor
A new instance of StarlingQueue.
- #length ⇒ Object
- #pop ⇒ Object
- #push(v) ⇒ Object
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
29 30 31 |
# File 'lib/super_poller/starling_queue.rb', line 29 def any? !empty? end |
#empty? ⇒ Boolean
25 26 27 |
# File 'lib/super_poller/starling_queue.rb', line 25 def empty? length.zero? end |
#fetch ⇒ Object
17 18 19 |
# File 'lib/super_poller/starling_queue.rb', line 17 def fetch @queue.fetch(@queue_name) end |
#flush ⇒ Object
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. =~ /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 |
#length ⇒ Object
21 22 23 |
# File 'lib/super_poller/starling_queue.rb', line 21 def length @queue.sizeof(@queue_name) end |
#pop ⇒ Object
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 |