Class: MemoryTracker::Stores::InMemoryStore::Manager

Inherits:
Base
  • Object
show all
Defined in:
lib/memory_tracker/stores/in_memory_store.rb

Instance Method Summary collapse

Methods inherited from Base

#name, register_store

Constructor Details

#initialize(opts = {}) ⇒ Manager

Returns a new instance of Manager.



7
8
9
10
11
12
# File 'lib/memory_tracker/stores/in_memory_store.rb', line 7

def initialize(opts = {})
  @length  = opts.fetch(:window_length, 60*60*4)

  @window1 = StatInterval.new(Time.now - @length/2, @length)
  @window2 = StatInterval.new(Time.now, @length)
end

Instance Method Details

#push(request) ⇒ Object



15
16
17
18
19
# File 'lib/memory_tracker/stores/in_memory_store.rb', line 15

def push(request)
  rotate_windows
  @window1.push(request)
  @window2.push(request)
end

#statsObject



21
22
23
24
# File 'lib/memory_tracker/stores/in_memory_store.rb', line 21

def stats
  rotate_windows
  @window1.stats
end