class Polipus::QueueOverflow::MongoQueueCapped
Public Class Methods
new(mongo_db, queue_name, options = {})
click to toggle source
Calls superclass method
Polipus::QueueOverflow::MongoQueue::new
# File lib/polipus/queue_overflow/mongo_queue_capped.rb, line 6 def initialize(mongo_db, queue_name, options = {}) super @max = @options[:max] end
Public Instance Methods
push(data)
click to toggle source
Calls superclass method
Polipus::QueueOverflow::MongoQueue#push
# File lib/polipus/queue_overflow/mongo_queue_capped.rb, line 11 def push(data) super @semaphore.synchronize do s = size if s > @max docs = @mongo_db[@collection_name].find.sort(_id: 1).projection(_id: 1).limit(s - @max).map { |e| e['_id'] } @mongo_db[@collection_name].find(_id: { '$in' => docs }).delete_many end end end