Class: Metering::MeteringRecord
- Inherits:
-
Object
- Object
- Metering::MeteringRecord
- Defined in:
- lib/ibm_appconfiguration_ruby_sdk/core/metering.rb
Overview
Inner class for storing metering records Tracks count and latest evaluation time with thread-safe operations
Instance Method Summary collapse
-
#get_count ⇒ Integer
Get the current count (thread-safe).
-
#get_latest_time ⇒ String
Get the latest evaluation time (thread-safe).
-
#increment(new_time) ⇒ Object
Increment the count and update latest time if newer.
-
#initialize(time) ⇒ MeteringRecord
constructor
Initialize a new metering record.
Constructor Details
#initialize(time) ⇒ MeteringRecord
Initialize a new metering record
78 79 80 81 82 |
# File 'lib/ibm_appconfiguration_ruby_sdk/core/metering.rb', line 78 def initialize(time) @count = 1 @latest_time = time @mutex = Mutex.new end |
Instance Method Details
#get_count ⇒ Integer
Get the current count (thread-safe)
99 100 101 |
# File 'lib/ibm_appconfiguration_ruby_sdk/core/metering.rb', line 99 def get_count @mutex.synchronize { @count } end |
#get_latest_time ⇒ String
Get the latest evaluation time (thread-safe)
107 108 109 |
# File 'lib/ibm_appconfiguration_ruby_sdk/core/metering.rb', line 107 def get_latest_time @mutex.synchronize { @latest_time } end |
#increment(new_time) ⇒ Object
Increment the count and update latest time if newer
88 89 90 91 92 93 |
# File 'lib/ibm_appconfiguration_ruby_sdk/core/metering.rb', line 88 def increment(new_time) @mutex.synchronize do @count += 1 @latest_time = new_time if new_time > @latest_time end end |