Django Error; how to empty tmp directory, cache

31 views
Skip to first unread message

DF

unread,
May 26, 2012, 3:37:55 AM5/26/12
to django...@googlegroups.com

A TemplateSyntaxError error has occurred in my previously functional project and after trying for hours to resolve it, it was determined it might be a cache error and to empty the tmp directory at the root (the template had been working fine for a week and nothing was changed that might have affected it).

I've searched online and can't seem to find a safe means of performing this. I don't want to inadvertently remove any essential information. If anyone knows how to perform this safely, it would be much appreciated. 

I found this but not sure if it's safe:

$ python manage.py shell

>>> from django.core.cache import cache
>>> cache.clear()

Russell Keith-Magee

unread,
May 26, 2012, 7:54:53 PM5/26/12
to django...@googlegroups.com
Whether this is "safe" will depend entirely on what else is in your
cache. cache.clear() dumps the full contents of your cache; if you're
using memcache, it's essentially the same as restarting memcache, but
without the service downtime.

The other way is to determine the specific cache key that you need to
flush, and delete that specific key (or keys) with
cache.delete('your_key_here').

This is one of the reasons that Django allows you to maintain multiple
cache backends. If you've got multiple types of information to cache,
having them all in the same cache means that if you call flush, you
lose *everything*; if you run multiple memcached instances, and use
Django's multiple cache backed interface to access them, you can
isolate the different types of cached information, and a flush will be
limited to contents of the specific cache.

Yours,
Russ Magee %-)
Reply all
Reply to author
Forward
0 new messages