Posts Tagged ‘cache’
Removing cache after shell script is done
Posted by primeminister | Filed under bash, Cake-Toppings
I have a scraper that runs every 6 hours and adds reviews, audio and video of the found music artists to our database. The problem is that I wanted to cache elements and views for minimum of 1 day and let the scraper remove the cache when it found new items.
Firts of all I use file caching. I tried with Clear::cache(false); at the end of the shell script but that didn’t work. I guess the file list is too long.
The I had a simple bash script that just stated
rm -f tmp/cache/views/element*
But the list was too long and it give ‘Argument too long‘ warnings. Then I had a look on the internet (Wait… what is that?) and created my own long-list-removable-view-files-bash-script:
#! /usr/bin/bash find ./tmp/cache -name 'cs_*' | xargs rm -f find ./tmp/cache -name 'cake_*' | xargs rm -f find ./tmp/cache/models -name 'cake_*' | xargs rm -f find ./tmp/cache/models -name 'musicbrainz_*' | xargs rm -f find ./tmp/cache/persistent -name 'cake_*' | xargs rm -f find ./tmp/cache/views -name 'element_*' | xargs rm -f
It does not only views removal, but I use this script also for new release deployment.
After I had finished this @savant pointed me to the PDF Math Curry where he pointed out the same… Damn!! :)
Cache duration and configuration tips
Posted by primeminister | Filed under Cake-Toppings
As you know you can cache several elements in you application. When I wrote a value to the cache I did it by setting the duration in the third parameter of write:
Cache::write('cache_key', 'value to cache',array(
'config'=>'default',
'duration'=>'+1 day')
);
But today I learned a lesson from Mark Story that this was a bug and it is fixed and doens’t work anymore. It is ignored.
So how do I set the duration before read/write for specific data in my code? (more…)