mirror of
https://github.com/moebooru/moebooru
synced 2025-08-22 09:57:31 +00:00
Fix cache key
This commit is contained in:
parent
d41daeeda9
commit
7d1e2d7c3c
@ -1,4 +1,6 @@
|
|||||||
class ForumPost < ApplicationRecord
|
class ForumPost < ApplicationRecord
|
||||||
|
LATEST_CACHE_KEY = 'forum_posts_latest_v4'
|
||||||
|
|
||||||
belongs_to :creator, class_name: "User", foreign_key: :creator_id
|
belongs_to :creator, class_name: "User", foreign_key: :creator_id
|
||||||
belongs_to :updater, class_name: "User", foreign_key: :last_updated_by
|
belongs_to :updater, class_name: "User", foreign_key: :last_updated_by
|
||||||
after_create :initialize_last_updated_by
|
after_create :initialize_last_updated_by
|
||||||
@ -156,7 +158,7 @@ class ForumPost < ApplicationRecord
|
|||||||
|
|
||||||
def clear_cache
|
def clear_cache
|
||||||
Rails.cache.delete "forum_posts"
|
Rails.cache.delete "forum_posts"
|
||||||
Rails.cache.delete "forum_posts_latest_v3"
|
Rails.cache.delete LATEST_CACHE_KEY
|
||||||
end
|
end
|
||||||
|
|
||||||
def last_updater
|
def last_updater
|
||||||
|
@ -204,7 +204,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script id="forum-posts-latest" type="application/json">
|
<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
|
ForumPost.latest.map { |p| p.slice(:id, :pages, :title, :updated_at) }.to_json.html_safe
|
||||||
end %>
|
end %>
|
||||||
</script>
|
</script>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user