Invalidate sort result cache after change sort_title

This commit is contained in:
Leeingnyo
2021-12-25 22:12:09 +09:00
parent 45ffa3d428
commit edfef80e5c
3 changed files with 22 additions and 4 deletions

View File

@@ -300,9 +300,18 @@ class Title
@title
end
def sort_title=(sort_title : String | Nil)
def set_sort_title(sort_title : String | Nil, username : String)
Storage.default.set_title_sort_title id, sort_title
@sort_title = sort_title
[false, true].each do |ascend|
[SortMethod::Auto, SortMethod::Title].each do |sort_method|
sorted_entries_cache_key =
SortedEntriesCacheEntry.gen_key @id, username, @entries,
SortOptions.new(sort_method, ascend)
LRUCache.invalidate sorted_entries_cache_key
end
end
end
def sort_title_db