otwarchive-symphonyarchive/lib/work_chapter_count_caching.rb
2026-03-11 22:22:11 +00:00

15 lines
442 B
Ruby

# This module is included by both the work and chapter models
module WorkChapterCountCaching
def key_for_chapter_posted_counting(work)
"/v1/chapters_posted/#{work.id}"
end
def key_for_chapter_total_counting(work)
"/v1/chapters_total/#{work.id}"
end
def invalidate_work_chapter_count(work)
Rails.cache.delete(key_for_chapter_total_counting(work))
Rails.cache.delete(key_for_chapter_posted_counting(work))
end
end