Class: INatGet::App::Server::API::Cache Private
- Inherits:
-
Object
- Object
- INatGet::App::Server::API::Cache
- Defined in:
- lib/inat-get/app/core/api_cache.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Instance Method Summary collapse
- #delete(key) ⇒ Object private
-
#initialize(limit = 100) ⇒ Cache
constructor
private
A new instance of Cache.
- #read(key) ⇒ Object private
- #write(key, value) ⇒ Object private
Constructor Details
#initialize(limit = 100) ⇒ Cache
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.
Returns a new instance of Cache.
14 15 16 17 |
# File 'lib/inat-get/app/core/api_cache.rb', line 14 def initialize limit = 100 @limit = limit @data = {} end |
Instance Method Details
#delete(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.
33 34 35 |
# File 'lib/inat-get/app/core/api_cache.rb', line 33 def delete key @data.delete key end |
#read(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.
19 20 21 22 23 24 |
# File 'lib/inat-get/app/core/api_cache.rb', line 19 def read key return nil unless @data.has_key?(key) value = @data.delete key @data[key] = value value end |
#write(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.
26 27 28 29 30 31 |
# File 'lib/inat-get/app/core/api_cache.rb', line 26 def write key, value @data.delete key @data[key] = value @data.shift if @data.size > @limit value end |