Reputation: 319
I have a slim fragment like this:
- cache [@user, :user_show, 'v2'] do
but we are concerned about our hit / miss rate and would like to log this. Is there an easy way to do this? I was thinking I could could Rails.cache.exist?
but I'd need to know more than what I have here (namely the template digest). Any ideas how to check for the existence of a cached fragment?
Upvotes: 2
Views: 488
Reputation: 15838
I think you can use controller.fragment_exist?
for that https://apidock.com/rails/v5.2.3/AbstractController/Caching/Fragments/fragment_exist%3F
And you should be able to use cache_fragment_name
to get the actual key https://apidock.com/rails/v5.2.3/ActionView/Helpers/CacheHelper/cache_fragment_name
Upvotes: 3