def flush(request): # Using raw umemcache flush_all function #defaultcache = umemcache.Client(settings.CACHES['default']['LOCATION']) #defaultcache.connect() #defaultcache.flush_all() #tilecache = umemcache.Client(settings.CACHES['tiles']['LOCATION']) #tilecache.connect() #tilecache.flush_all() #resultscache = umemcache.Client(settings.CACHES['tiles']['LOCATION']) #resultscache.connect() #resultscache.flush_all() #==# # Using custom clear function from https://github.com/mozilla/django-memcached-pool/blob/master/memcachepool/cache.py if(check_cache_availability(settings.CACHES['default']['LOCATION'], settings.CACHES['default'])): defaultcache = caches['default'] defaultcache.clear() if(check_cache_availability(settings.CACHES['tiles']['LOCATION'], settings.CACHES['tiles'])): tilecache = caches['tiles'] tilecache.clear() if(check_cache_availability(settings.CACHES['celery_results']['LOCATION'], settings.CACHES['celery_results'])): resultscache = caches['celery_results'] resultscache.clear() return HttpResponse("Tile cache flushed.", content_type="text/plain" )
def stats_cache_json(request): stats = {} target = settings.TILEJET['cache']['memory']['target'] if(check_cache_availability(settings.CACHES[target]['LOCATION'], settings.CACHES[target])): location = settings.CACHES[target]['LOCATION'] tilecache = umemcache.Client(location) tilecache.connect() stats = tilecache.stats() return HttpResponse(json.dumps(stats), content_type="application/json" )