2
0
mirror of https://github.com/moebooru/moebooru synced 2025-08-21 17:37:09 +00:00

Fix cache key

This commit is contained in:
nanaya 2025-01-12 19:08:10 +09:00
parent d41daeeda9
commit 7d1e2d7c3c
2 changed files with 4 additions and 2 deletions

View File

@ -1,4 +1,6 @@
class ForumPost < ApplicationRecord
LATEST_CACHE_KEY = 'forum_posts_latest_v4'
belongs_to :creator, class_name: "User", foreign_key: :creator_id
belongs_to :updater, class_name: "User", foreign_key: :last_updated_by
after_create :initialize_last_updated_by
@ -156,7 +158,7 @@ class ForumPost < ApplicationRecord
def clear_cache
Rails.cache.delete "forum_posts"
Rails.cache.delete "forum_posts_latest_v3"
Rails.cache.delete LATEST_CACHE_KEY
end
def last_updater

View File

@ -204,7 +204,7 @@
</div>
<script id="forum-posts-latest" type="application/json">
<%= Rails.cache.fetch "forum_posts_latest_v4" do
<%= Rails.cache.fetch ForumPost::LATEST_CACHE_KEY do
ForumPost.latest.map { |p| p.slice(:id, :pages, :title, :updated_at) }.to_json.html_safe
end %>
</script>