Replace InfoCache to LRUCache

This commit is contained in:
Leeingnyo
2021-09-05 01:54:19 +09:00
parent 0fd7caef4b
commit de410f42b8
6 changed files with 61 additions and 190 deletions
+4 -3
View File
@@ -35,15 +35,16 @@ class SortOptions
end
def self.from_info_json(dir, username)
cached_opt = InfoCache.get_sort_opt dir, username
return cached_opt if cached_opt
key = "#{dir}:#{username}:sort_opt"
cached_opt = LRUCache.get key
return cached_opt if cached_opt.is_a? SortOptions
opt = SortOptions.new
TitleInfo.new dir do |info|
if info.sort_by.has_key? username
opt = SortOptions.from_tuple info.sort_by[username]
end
end
InfoCache.set_sort_opt dir, username, opt
LRUCache.set generate_cache_entry key, opt
opt
end