module EventMachine::Bucketer::Ordered::Database::Hash

Private Instance Methods

add_item_to_db(bucket_id, item, &blk) click to toggle source
# File lib/em-bucketer/ordered/database/hash.rb, line 39
def add_item_to_db(bucket_id, item, &blk)
  EM::Completion.new.tap do |c|
    c.callback(&blk) if block_given?
    bucket_by_id(bucket_id) << item
    c.succeed
  end
end
bucket_by_id(bucket_id) click to toggle source
# File lib/em-bucketer/ordered/database/hash.rb, line 62
def bucket_by_id(bucket_id)
  @buckets[bucket_id] ||= []
end
bucket_size_from_db(bucket_id, &blk) click to toggle source
# File lib/em-bucketer/ordered/database/hash.rb, line 32
def bucket_size_from_db(bucket_id, &blk)
  EM::Completion.new.tap do |c|
    c.callback(&blk) if block_given?
    c.succeed bucket_by_id(bucket_id).count
  end
end
empty_bucket_in_db(bucket_id, &blk) click to toggle source
# File lib/em-bucketer/ordered/database/hash.rb, line 54
def empty_bucket_in_db(bucket_id, &blk)
  EM::Completion.new.tap do |c|
    c.callback(&blk) if block_given?
    @buckets[bucket_id] = []
    c.succeed
  end
end
get_bucket_from_db(bucket_id, &blk) click to toggle source
# File lib/em-bucketer/ordered/database/hash.rb, line 47
def get_bucket_from_db(bucket_id, &blk)
  EM::Completion.new.tap do |c|
    c.callback(&blk) if block_given?
    c.succeed bucket_by_id(bucket_id)
  end
end
pop_all_from_db(bucket_id, &blk) click to toggle source
# File lib/em-bucketer/ordered/database/hash.rb, line 13
def pop_all_from_db(bucket_id, &blk)
  EM::Completion.new.tap do |c|
    c.callback(&blk) if block_given?
    all = bucket_by_id(bucket_id)
    @buckets[bucket_id] = []
    c.succeed all
  end
end
pop_count_from_db(bucket_id, count, &blk) click to toggle source
# File lib/em-bucketer/ordered/database/hash.rb, line 22
def pop_count_from_db(bucket_id, count, &blk)
  EM::Completion.new.tap do |c|
    c.callback(&blk) if block_given?
    all = bucket_by_id(bucket_id)
    result = all.first(count)
    @buckets[bucket_id] = all[count..-1]
    c.succeed result
  end
end
setup_db() click to toggle source
# File lib/em-bucketer/ordered/database/hash.rb, line 9
def setup_db
  @buckets = {}
end