Class: OpenWeatherClient::Caching::Memory

Inherits:
OpenWeatherClient::Caching show all
Defined in:
lib/open_weather_client/caching/memory.rb

Overview

Memory cache of OpenWeatherMap requests

The requests are cached in memory up to the number specified in config.max_memory_entries. When the limit is reached the least recently used entry is evicted.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from OpenWeatherClient::Caching

#cache_key, #get, #store

Constructor Details

#initializeMemory

Initialize an empty cache



18
19
20
21
22
# File 'lib/open_weather_client/caching/memory.rb', line 18

def initialize
  super
  @memory_cache = {}
  @memory_keys = []
end

Instance Attribute Details

#memory_cacheObject (readonly)

Memory cache to store a hash of keys and request data



12
13
14
# File 'lib/open_weather_client/caching/memory.rb', line 12

def memory_cache
  @memory_cache
end

#memory_keysObject (readonly)

Key registry of the memory cache. The first entry is the key of the least recently accessed data



14
15
16
# File 'lib/open_weather_client/caching/memory.rb', line 14

def memory_keys
  @memory_keys
end