Method: Redisrank::Buffer#store
- Defined in:
- lib/redisrank/buffer.rb
#store(key, stats, depth_limit, opts) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/redisrank/buffer.rb', line 27 def store(key, stats, depth_limit, opts) return false unless should_buffer? to_flush = {} buffkey = buffer_key(key, opts) synchronize do if !queue.has_key?(buffkey) queue[buffkey] = { :key => key, :stats => {}, :depth_limit => depth_limit, :opts => opts } end queue[buffkey][:stats].merge_to_max!(stats) incr_count # return items to be flushed if buffer size limit has been reached to_flush = reset_queue end # flush any data that's been cleared from the queue flush_data(to_flush) true end |