Class: Trifle::Stats::BufferQueue
- Inherits:
-
Object
- Object
- Trifle::Stats::BufferQueue
- Defined in:
- lib/trifle/stats/buffer.rb
Instance Method Summary collapse
- #drain ⇒ Object
- #empty? ⇒ Boolean
-
#initialize(aggregate:) ⇒ BufferQueue
constructor
A new instance of BufferQueue.
- #size ⇒ Object
- #store(operation, keys, values, tracking_key) ⇒ Object
Constructor Details
#initialize(aggregate:) ⇒ BufferQueue
Returns a new instance of BufferQueue.
103 104 105 106 |
# File 'lib/trifle/stats/buffer.rb', line 103 def initialize(aggregate:) @aggregate = aggregate reset! end |
Instance Method Details
#drain ⇒ Object
125 126 127 128 129 |
# File 'lib/trifle/stats/buffer.rb', line 125 def drain drained = aggregate? ? @actions.values : @actions.dup reset! drained end |
#empty? ⇒ Boolean
121 122 123 |
# File 'lib/trifle/stats/buffer.rb', line 121 def empty? size.zero? end |
#size ⇒ Object
117 118 119 |
# File 'lib/trifle/stats/buffer.rb', line 117 def size @operation_count end |
#store(operation, keys, values, tracking_key) ⇒ Object
108 109 110 111 112 113 114 115 |
# File 'lib/trifle/stats/buffer.rb', line 108 def store(operation, keys, values, tracking_key) if aggregate? store_aggregate(operation, keys, values, tracking_key) else store_linear(operation, keys, values, tracking_key) end @operation_count += 1 end |