Module: Airbrake::FileCache Private
- Defined in:
- lib/airbrake-ruby/file_cache.rb
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Extremely simple global cache.
Constant Summary collapse
- MAX_SIZE =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
50
- MUTEX =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Mutex.new
Class Method Summary collapse
-
.[](key) ⇒ Object
private
Retrieve an object from the cache.
-
.[]=(key, value) ⇒ Object
private
Associates the value given by
value
with the key given bykey
. -
.empty? ⇒ Boolean
private
Checks whether the cache is empty.
- .reset ⇒ void private
Class Method Details
.[](key) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Retrieve an object from the cache.
30 31 32 33 34 |
# File 'lib/airbrake-ruby/file_cache.rb', line 30 def self.[](key) MUTEX.synchronize do data[key] end end |
.[]=(key, value) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Associates the value given by value
with the key given by key
. Deletes entries that exceed MAX_SIZE
.
19 20 21 22 23 24 |
# File 'lib/airbrake-ruby/file_cache.rb', line 19 def self.[]=(key, value) MUTEX.synchronize do data[key] = value data.delete(data.keys.first) if data.size > MAX_SIZE end end |
.empty? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Checks whether the cache is empty. Needed only for the test suite.
39 40 41 |
# File 'lib/airbrake-ruby/file_cache.rb', line 39 def self.empty? data.empty? end |
.reset ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
45 46 47 |
# File 'lib/airbrake-ruby/file_cache.rb', line 45 def self.reset @data = {} end |