Allow for cache timers to be adjusted on a per path basis

This commit is contained in:
2011-12-04 03:44:27 +00:00
parent 865a0ff57e
commit 39d588e6f9
2 changed files with 14 additions and 1 deletions

View File

@@ -95,6 +95,13 @@ LOGIN_URL = "/login"
OAUTH_AUTH_VIEW = 'api.views.oauth_auth_view'
OAUTH_CALLBACK_VIEW = 'api.views.oauth_callback_view'
## EVE Proxy
# Manual adjustments to cache timers (lowercase path)
EVE_PROXY_CACHE_ADJUSTMENTS = {
'/api/calllist.xml.aspx': 3600,
}
### Celery Schedule
from celeryschedule import *

View File

@@ -114,7 +114,13 @@ class CachedDocumentManager(models.Manager):
else:
date = datetime.strptime(dom.getElementsByTagName('cachedUntil')[0].childNodes[0].nodeValue, '%Y-%m-%d %H:%M:%S')
# Add 30 seconds to the cache timers, avoid hitting too early and account for some minor clock skew.
doc.cached_until = date + timedelta(seconds=getattr(settings, 'EVE_PROXY_CACHE_ADJUSTMENT', 30))
doc.cached_until = date + timedelta(seconds=getattr(settings, 'EVE_PROXY_GLOBAL_CACHE_ADJUSTMENT', 30))
# Allow for tuning of individual pages with bad cache returns
adjustconfig = getattr(settings, 'EVE_PROXY_CACHE_ADJUSTMENTS', {})
if url_path.lower() in adjustconfig:
doc.cached_until = date + timedelta(seconds=adjustconfig[url_path.lower()])
enode = dom.getElementsByTagName('error')
if enode:
error = enode[0].getAttribute('code')