Remove cache in cake php use it The Motivation


The Motivation

1. When you work with large projects you can end up with a ton of cache files (models, db cache, etc.) as well as view caching files. When you try removing them with:

cd /app/tmp/cache/models && rm -f cake_*

and

cd /app/tmp/cache/views && rm -f *

.. you can end up with with the “argument list too long” error easily.

2. Also, executing two commands sucks – we are lazy after all. Now you could pull out some fancy bash fun to pipe file names. Have a look at this:

find . -type f | awk ‘!/empty/ {print “rm”, $0}’ | bash

The problem is, when you run this in /app/tmp it will not only remove cache files, but also files in /tmp/sessions, /tmp/logs and so on. If you ask me, the command is complex enough, so no need to add more funny stuff there to take this into account.

(For you peeps who want to see this, I bugged Felix to tell me: find . -type f | awk ‘!/empty$|^.\/logs|^.\/sessions/ {print “rm”, $0}’ | bash)

3. Once you are on windows, you do not have a powerful bash to your side.

I thought a simple call to a CakePHP shell can do the trick as well and doesn’t force you to waste half a minute to remember and type in the proper bash command.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s