Class: SolidObserver::Services::CacheStats::TrendData::BucketSnapshot

Inherits:
Object
  • Object
show all
Defined in:
lib/solid_observer/services/cache_stats.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeBucketSnapshot

Returns a new instance of BucketSnapshot.



39
40
41
42
43
44
# File 'lib/solid_observer/services/cache_stats.rb', line 39

def initialize
  @operations_count = 0
  @hits_count = 0
  @misses_count = 0
  @errors_count = 0
end

Instance Attribute Details

#errors_countObject (readonly)

Returns the value of attribute errors_count.



37
38
39
# File 'lib/solid_observer/services/cache_stats.rb', line 37

def errors_count
  @errors_count
end

#hits_countObject (readonly)

Returns the value of attribute hits_count.



37
38
39
# File 'lib/solid_observer/services/cache_stats.rb', line 37

def hits_count
  @hits_count
end

#misses_countObject (readonly)

Returns the value of attribute misses_count.



37
38
39
# File 'lib/solid_observer/services/cache_stats.rb', line 37

def misses_count
  @misses_count
end

#operations_countObject (readonly)

Returns the value of attribute operations_count.



37
38
39
# File 'lib/solid_observer/services/cache_stats.rb', line 37

def operations_count
  @operations_count
end

Instance Method Details

#add(row) ⇒ Object



46
47
48
49
50
51
# File 'lib/solid_observer/services/cache_stats.rb', line 46

def add(row)
  @operations_count += row[1].to_i
  @hits_count += row[2].to_i
  @misses_count += row[3].to_i
  @errors_count += row[4].to_i
end

#hit_rateObject



53
54
55
56
57
58
# File 'lib/solid_observer/services/cache_stats.rb', line 53

def hit_rate
  read_outcomes = hits_count + misses_count
  return 0.0 if read_outcomes.zero?

  hits_count.to_f / read_outcomes
end

#value_for(key) ⇒ Object



60
61
62
# File 'lib/solid_observer/services/cache_stats.rb', line 60

def value_for(key)
  public_send(key)
end