From 7e094f3a37ceafea6f9352d034831d56412c57b5 Mon Sep 17 00:00:00 2001 From: Andrew Williams Date: Fri, 4 Jun 2010 09:00:51 +0100 Subject: [PATCH] Added FlushCache cronjob, also fixed output message for ClearStaleCache --- eve_proxy/cron.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/eve_proxy/cron.py b/eve_proxy/cron.py index e028eac..55ebed2 100644 --- a/eve_proxy/cron.py +++ b/eve_proxy/cron.py @@ -16,5 +16,22 @@ class ClearStaleCache(): def job(self): objs = CachedDocument.objects.filter(cached_until__lt=datetime.utcnow()) - self._logger.info('Removing %s stale cache documents') + self._logger.info('Removing %s stale cache documents' % len(objs)) objs.delete() + +class FlushCache(): + """ + Flushes the entire cache + """ + + @property + def _logger(self): + if not hasattr(self, '__logger'): + self.__logger = logging.getLogger(__name__) + return self.__logger + + def job(self): + objs = CachedDocument.objects.all() + self._logger.info('Removing %s stale cache documents' % len(objs)) + objs.delete() +