Class: TimeWindowDropCollector::Storage
- Inherits:
-
Object
- Object
- TimeWindowDropCollector::Storage
- Includes:
- Utils
- Defined in:
- lib/time_window_drop_collector/storage.rb
Instance Attribute Summary collapse
-
#slices ⇒ Object
readonly
Returns the value of attribute slices.
-
#window ⇒ Object
readonly
Returns the value of attribute window.
-
#wrapper ⇒ Object
readonly
Returns the value of attribute wrapper.
Instance Method Summary collapse
- #count(keys) ⇒ Object
- #decr(timestamp, keys, amount = 1) ⇒ Object
- #incr(keys, amount = 1) ⇒ Object
-
#initialize(wrapper, window, slices) ⇒ Storage
constructor
A new instance of Storage.
Methods included from Utils
#grouping_count, #slice_milliseconds, #slice_start_timestamp, #timestamp, #timestamp_key, #timestamp_key_multi, #window_keys, #window_keys_multi
Constructor Details
#initialize(wrapper, window, slices) ⇒ Storage
Returns a new instance of Storage.
6 7 8 9 10 |
# File 'lib/time_window_drop_collector/storage.rb', line 6 def initialize( wrapper, window, slices ) @wrapper = wrapper @window = window @slices = slices end |
Instance Attribute Details
#slices ⇒ Object (readonly)
Returns the value of attribute slices.
4 5 6 |
# File 'lib/time_window_drop_collector/storage.rb', line 4 def slices @slices end |
#window ⇒ Object (readonly)
Returns the value of attribute window.
4 5 6 |
# File 'lib/time_window_drop_collector/storage.rb', line 4 def window @window end |
#wrapper ⇒ Object (readonly)
Returns the value of attribute wrapper.
4 5 6 |
# File 'lib/time_window_drop_collector/storage.rb', line 4 def wrapper @wrapper end |
Instance Method Details
#count(keys) ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'lib/time_window_drop_collector/storage.rb', line 22 def count( keys ) return {} if keys.empty? window_keys = window_keys_multi( keys ) keys_values = wrapper.get( window_keys ) grouping_count( keys_values ) end |
#decr(timestamp, keys, amount = 1) ⇒ Object
18 19 20 |
# File 'lib/time_window_drop_collector/storage.rb', line 18 def decr( , keys, amount=1 ) wrapper.decr(( keys, ), window, amount) end |
#incr(keys, amount = 1) ⇒ Object
12 13 14 15 16 |
# File 'lib/time_window_drop_collector/storage.rb', line 12 def incr( keys, amount=1 ) now = Time.now wrapper.incr( ( keys, now), window, amount ) now end |