otwa-aggie/lib/work_chapter_count_caching.rb
2026-08-13 00:44:25 -04: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