From f33e5cd2d4a33a1672d1ce60e58ccfd893dc098f Mon Sep 17 00:00:00 2001 From: apainintheneck Date: Tue, 20 Feb 2024 17:36:57 -0800 Subject: [PATCH] Fix caching bug We had a cache when loading the cached json and text files which was not actually caching anything. This caused files to be read from disk in a loop instead of just being read the first time. --- lib/atlasq/cache.rb | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/lib/atlasq/cache.rb b/lib/atlasq/cache.rb index 8fbf2cc..0e1abc8 100644 --- a/lib/atlasq/cache.rb +++ b/lib/atlasq/cache.rb @@ -13,14 +13,11 @@ def self.get(full_name) @get ||= {} @get.fetch(full_name) do path = "#{CACHE_DIR}/#{full_name}" + content = File.read(path) + content = JSON.parse(content) if full_name.end_with?(".json") - case full_name - when /\.json$/ - JSON.parse(content) - else - content - end + @get[full_name] = content end end end