Skip to content

Instantly share code, notes, and snippets.

@tmlangley
Last active August 29, 2015 14:23
Show Gist options
  • Save tmlangley/8c7fa1f8a73b3e675378 to your computer and use it in GitHub Desktop.
Save tmlangley/8c7fa1f8a73b3e675378 to your computer and use it in GitHub Desktop.
Drush cache clear
# Clear specific drupal cache table with drush
# $1 - Cache table or "theme" for css-js.
# $2 - Environment drush alias. Ex: @mysite.dev
_drcc() {
# alias "css-js" to "theme" because I can never remember which comes first.
if [ "$1" == "theme" ] ; then
table="css-js"
else
table=$1
fi
if [ -z "$2" ]; then
# Redirect the output to /dev/null so we can do a custom message.
drush cc "$table" &> /dev/null
echo "Cleared $table cache on the current environment."
else
# Redirect the output to /dev/null so we can do a custom message.
drush "$2" cc "$table" &> /dev/null
echo "Cleared $table cache on $2."
fi
}
alias drcc="_drcc"
@tmlangley
Copy link
Author

Examples

Clear menu cache on @mysite.dev:

drcc menu @mysite.dev

Clear css-js cache on the current local environment:

drcc css-js

or...

drcc theme

This works because "theme" has been aliased to "css-js" since I can never remember if it's "css-js" or "js-css"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment