I've got a list of products in my system and a master list of products
available from my distributor. Every night I import a new
distributor product file and update the prices for my list of products
if any of them have changed.
The code to import the new distributor catalog file runs from a rake
task in my crontab and all of my products/show pages are cached, as
well as my index pages, so after updating all the prices, the system
still displays the old cached price.
I need to be able to expire the cache fragments from one of the models
that deals with downloading and importing the new distributor catalog
file, but as far as I can tell, it's not possible to execute the cache
expiration methods from a model. Is there any way I can manually
expire these caches? Or call my cache_sweeper from the model? My
ProductSweeper looks something like this:
def after_save(product)
expire_fragment(product_path(product))
#expire some more stuff here...
end
The other option is to not cache the product price, which will require
me to go through all my code and end my cache blocks before the price
is displayed, then start the cache block afterwards, but I'd have to
use two separate cache names, like 'product_info_top' and
'product_info_bottom', which starts to get messy and something I
wanted to avoid. I can't find any sort of "no_cache" specifier to
wrap around a value in a cached block.. Would be very useful..
So I'm wondering if anyone has any advice or suggestions.. Thanks in
advance for your help!