Sha256: c223ceec9cc53c97e986cd6fa276d9a2ef693a0b91340bce433fecf138b17750
Contents?: true
Size: 950 Bytes
Versions: 19
Compression:
Stored size: 950 Bytes
Contents
module SplitIoClient module Cache module Adapters module MemoryAdapters # Memory adapter implementation, which stores everything inside sized queue class SizedQueueAdapter def initialize(size) @size = size @queue = SizedQueue.new(queue_size) end # Adds data to queue in non-blocking mode def add_to_queue(data) # IMPORTANT: this requires Ruby >= 2.2, consider changing implementation @queue.push(data, true) end # Get all items from the queue def clear items = [] loop { items << @queue.pop(true) } rescue ThreadError # Last queue item reached items end private # Return 1 to prevent an exception def queue_size @size <= 0 ? 1 : @size end end end end end end
Version data entries
19 entries across 19 versions & 1 rubygems