mirror of
https://github.com/nikdoof/test-auth.git
synced 2025-12-14 06:42:16 +00:00
Added functions to clear old cache documents
This commit is contained in:
@@ -6,3 +6,4 @@ ROOT=/home/matalok/auth/auth
|
||||
@hourly $ROOT/run-cron.py sso.cron RemoveInvalidUsers > $ROOT/logs/auth-update.log 2>&1
|
||||
@daily $ROOT/run-cron.py registration.cron RemoveExpiredProfiles > /dev/null 2>&1
|
||||
@daily $ROOT/run-cron.py eve_api.cron CorpManagementUpdate > $ROOT/logs/corpman-update.log 2>&1
|
||||
@daily $ROOT/run-cron.py eve_proxy.cron ClearStaleCache > $ROOT/logs/cache-clear.log 2>&1
|
||||
|
||||
20
eve_proxy/cron.py
Normal file
20
eve_proxy/cron.py
Normal file
@@ -0,0 +1,20 @@
|
||||
import logging
|
||||
from datetime import datetime
|
||||
|
||||
from eve_proxy.models import CachedDocument
|
||||
|
||||
class ClearStaleCache():
|
||||
"""
|
||||
Clears out any stale cache entries
|
||||
"""
|
||||
|
||||
@property
|
||||
def _logger(self):
|
||||
if not hasattr(self, '__logger'):
|
||||
self.__logger = logging.getLogger(__name__)
|
||||
return self.__logger
|
||||
|
||||
def job(self):
|
||||
objs = CachedDocument.objects.filter(cached_until__lt=datetime.utcnow())
|
||||
self._logger.info('Removing %s stale cache documents')
|
||||
objs.delete()
|
||||
Reference in New Issue
Block a user