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.



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

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

Instance Method Details

#[](key) ⇒ Object



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

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

#bump(key) ⇒ Object



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

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

#set(key, value) ⇒ Object



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

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

#to_sObject



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

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