Class: IbmAppconfigurationRubySdk::Metering::MeteringRecord
- Inherits:
-
Object
- Object
- IbmAppconfigurationRubySdk::Metering::MeteringRecord
- Defined in:
- lib/ibm_appconfiguration_ruby_sdk/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
65 66 67 68 69 |
# File 'lib/ibm_appconfiguration_ruby_sdk/metering.rb', line 65 def initialize(time) @count = 1 @latest_time = time @mutex = Mutex.new end |
Instance Method Details
#get_count ⇒ Integer
Get the current count (thread-safe)
86 87 88 |
# File 'lib/ibm_appconfiguration_ruby_sdk/metering.rb', line 86 def get_count @mutex.synchronize { @count } end |
#get_latest_time ⇒ String
Get the latest evaluation time (thread-safe)
94 95 96 |
# File 'lib/ibm_appconfiguration_ruby_sdk/metering.rb', line 94 def get_latest_time @mutex.synchronize { @latest_time } end |
#increment(new_time) ⇒ Object
Increment the count and update latest time if newer
75 76 77 78 79 80 |
# File 'lib/ibm_appconfiguration_ruby_sdk/metering.rb', line 75 def increment(new_time) @mutex.synchronize do @count += 1 @latest_time = new_time if new_time > @latest_time end end |