mirror of
https://github.com/hkalexling/Mango.git
synced 2026-04-25 00:00:52 -04:00
Implement sorted entries cache
sorted_entries cached
This commit is contained in:
@@ -344,6 +344,10 @@ class Title
|
||||
# use the default (auto, ascending)
|
||||
# When `opt` is not nil, it saves the options to info.json
|
||||
def sorted_entries(username, opt : SortOptions? = nil)
|
||||
cache_key = SortedEntriesCache.gen_key @id, username, @entries, opt
|
||||
cached_entries = SortedEntriesCache.get cache_key
|
||||
return cached_entries if cached_entries
|
||||
|
||||
if opt.nil?
|
||||
opt = SortOptions.from_info_json @dir, username
|
||||
end
|
||||
@@ -377,6 +381,7 @@ class Title
|
||||
|
||||
ary.reverse! unless opt.not_nil!.ascend
|
||||
|
||||
SortedEntriesCache.set cache_key, ary
|
||||
ary
|
||||
end
|
||||
|
||||
@@ -442,6 +447,12 @@ class Title
|
||||
parents.each do |parent|
|
||||
InfoCache.invalidate_progress_cache parent.id, username
|
||||
end
|
||||
[false, true].each do |ascend|
|
||||
sorted_entries_cache_key =
|
||||
SortedEntriesCache.gen_key @id, username, @entries,
|
||||
SortOptions.new(SortMethod::Progress, ascend)
|
||||
SortedEntriesCache.invalidate sorted_entries_cache_key
|
||||
end
|
||||
|
||||
selected_entries = ids
|
||||
.map { |id|
|
||||
|
||||
Reference in New Issue
Block a user