Class: LogLocationCache

Inherits:
Object
  • Object
show all
Defined in:
lib/runit-man/log_location_cache.rb

Constant Summary collapse

TIME_LIMIT =
600

Instance Method Summary collapse

Constructor Details

#initialize(logger) ⇒ LogLocationCache

Returns a new instance of LogLocationCache.



6
7
8
9
10
# File 'lib/runit-man/log_location_cache.rb', line 6

def initialize(logger)
  @logger = logger
  @monitor = Monitor.new
  clear
end

Instance Method Details

#[](pid) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/runit-man/log_location_cache.rb', line 12

def [](pid)
  pid = pid.to_i
  loc = nil
  unless pids.include?(pid)
    loc = get_pid_location(pid)
    set_pid_log_location(pid, loc)
  end
  return loc unless loc.nil?
  return nil unless pids.include?(pid)
  pids[pid][:value]
end