module Airbrake::FileCache
Extremely simple global cache.
@api private @since v2.4.1
Constants
- MAX_SIZE
@return [Integer]
- MUTEX
@return [Mutex]
Public Class Methods
[](key)
click to toggle source
Retrieve an object from the cache.
@param [Object] key @return [Object] the corresponding value
# File lib/airbrake-ruby/file_cache.rb, line 35 def self.[](key) MUTEX.synchronize do data[key] end end
[]=(key, value)
click to toggle source
Associates the value given by value
with the key given by key
. Deletes entries that exceed MAX_SIZE
.
@param [Object] key @param [Object] value @return [Object] the corresponding value
# File lib/airbrake-ruby/file_cache.rb, line 23 def self.[]=(key, value) MUTEX.synchronize do data[key] = value data.delete(data.keys.first) if data.size > MAX_SIZE end end
empty?()
click to toggle source
Checks whether the cache is empty. Needed only for the test suite.
@return [Boolean]
# File lib/airbrake-ruby/file_cache.rb, line 45 def self.empty? data.empty? end
Private Class Methods
data()
click to toggle source
# File lib/airbrake-ruby/file_cache.rb, line 49 def self.data @data ||= {} end