Module: Jat::Plugins::JsonApiMapsCache::MapsCacheClassMethods
- Defined in:
- lib/jat/plugins/json_api/plugins/json_api_maps_cache/json_api_maps_cache.rb
Instance Method Summary collapse
-
#maps_cache ⇒ Object
Caches up to ‘:cached_maps_count` maps for each serializer.
Instance Method Details
#maps_cache ⇒ Object
Caches up to ‘:cached_maps_count` maps for each serializer. Removes earliest value if new value exceeds limit.
27 28 29 30 31 32 |
# File 'lib/jat/plugins/json_api/plugins/json_api_maps_cache/json_api_maps_cache.rb', line 27 def maps_cache @maps_cache ||= Hash.new do |cache, cache_key| cache.shift if cache.length >= jat_class.config[:cached_maps_count] # protect from memory leak cache[cache_key] = EnumDeepFreeze.call(yield) end end |