Class: KubernetesMetadata::Stats

Inherits:
Object
  • Object
show all
Defined in:
lib/fluent/plugin/kubernetes_metadata_stats.rb

Instance Method Summary collapse

Constructor Details

#initializeStats

Returns a new instance of Stats.



23
24
25
# File 'lib/fluent/plugin/kubernetes_metadata_stats.rb', line 23

def initialize
  @stats = ::LruRedux::TTL::ThreadSafeCache.new(1000, 3600)
end

Instance Method Details

#[](key) ⇒ Object



35
36
37
# File 'lib/fluent/plugin/kubernetes_metadata_stats.rb', line 35

def [](key)
  @stats[key]
end

#bump(key) ⇒ Object



27
28
29
# File 'lib/fluent/plugin/kubernetes_metadata_stats.rb', line 27

def bump(key)
    @stats[key] = @stats.getset(key) { 0 } + 1
end

#set(key, value) ⇒ Object



31
32
33
# File 'lib/fluent/plugin/kubernetes_metadata_stats.rb', line 31

def set(key, value)
   @stats[key] = value
end

#to_sObject



39
40
41
42
43
# File 'lib/fluent/plugin/kubernetes_metadata_stats.rb', line 39

def to_s
  "stats - " + [].tap do |a|
      @stats.each {|k,v| a << "#{k.to_s}: #{v}"}
  end.join(', ')
end