[IMP] website_version: cache enable
The visitors who have the same sequence of versions for their running experiments must share the same cache.
This commit is contained in:
@@ -90,6 +90,9 @@ class ir_http(orm.AbstractModel):
|
||||
record = self._geoip_resolver.record_by_addr(request.httprequest.remote_addr) or {}
|
||||
request.session['geoip'] = record
|
||||
|
||||
def get_page_key(self):
|
||||
return (self._name, "cache", request.uid, request.lang, request.httprequest.full_path)
|
||||
|
||||
def _dispatch(self):
|
||||
first_pass = not hasattr(request, 'website')
|
||||
request.website = None
|
||||
@@ -168,7 +171,7 @@ class ir_http(orm.AbstractModel):
|
||||
cache_enable = cache_time and request.httprequest.method == "GET" and request.website.user_id.id == request.uid
|
||||
cache_response = None
|
||||
if cache_enable:
|
||||
key = (self._name, "cache", request.uid, request.lang, request.httprequest.full_path)
|
||||
key = self.get_page_key()
|
||||
try:
|
||||
r = self.pool.cache[key]
|
||||
if r['time'] + cache_time > time.time():
|
||||
|
||||
@@ -14,3 +14,8 @@ class ir_http(orm.AbstractModel):
|
||||
x.set_cookie('website_version_experiment', data)
|
||||
return x
|
||||
|
||||
def get_page_key(self):
|
||||
key = super(ir_http, self).get_page_key()
|
||||
seq_ver = [int(ver) for ver in request.context.get('website_version_experiment', {}).values()]
|
||||
key += (str(sorted(seq_ver)),)
|
||||
return key
|
||||
|
||||
Reference in New Issue
Block a user