Commit b064be3e authored by ibuler's avatar ibuler

[Bugfix] 修复用户页面不走cache的bug

parent c3308442
...@@ -151,7 +151,7 @@ function initTree() { ...@@ -151,7 +151,7 @@ function initTree() {
} }
$(document).ready(function () { $(document).ready(function () {
{#initTree();#} initTree();
initTable(); initTable();
}).on('click', '.labels li', function () { }).on('click', '.labels li', function () {
var val = $(this).text(); var val = $(this).text();
......
...@@ -58,7 +58,11 @@ class UserPermissionCacheMixin: ...@@ -58,7 +58,11 @@ class UserPermissionCacheMixin:
return None return None
def get_request_md5(self): def get_request_md5(self):
full_path = self.request.get_full_path() path = self.request.path
query = {k: v for k, v in self.request.GET.items()}
query.pop("_", None)
query = "&".join(["{}={}".format(k, v) for k, v in query.items()])
full_path = "{}?{}".format(path, query)
return md5(full_path.encode()).hexdigest() return md5(full_path.encode()).hexdigest()
def get_meta_cache_id(self): def get_meta_cache_id(self):
...@@ -83,9 +87,7 @@ class UserPermissionCacheMixin: ...@@ -83,9 +87,7 @@ class UserPermissionCacheMixin:
return None return None
# 从响应缓冲里获取响应 # 从响应缓冲里获取响应
key = self.get_response_key() key = self.get_response_key()
print("response key: {}".format(key))
data = cache.get(key) data = cache.get(key)
print(data)
if not data: if not data:
logger.debug("Not get response from cache: {}".format(key)) logger.debug("Not get response from cache: {}".format(key))
return None return None
...@@ -94,7 +96,6 @@ class UserPermissionCacheMixin: ...@@ -94,7 +96,6 @@ class UserPermissionCacheMixin:
return response return response
def expire_response_cache(self): def expire_response_cache(self):
print("Expire cache")
obj_id = self.get_object_id() obj_id = self.get_object_id()
expire_cache_id = '{}_{}'.format(obj_id, '*') expire_cache_id = '{}_{}'.format(obj_id, '*')
key = self.RESP_CACHE_KEY.format(expire_cache_id) key = self.RESP_CACHE_KEY.format(expire_cache_id)
...@@ -109,7 +110,6 @@ class UserPermissionCacheMixin: ...@@ -109,7 +110,6 @@ class UserPermissionCacheMixin:
key = self.get_response_key() key = self.get_response_key()
cache.set(key, response.data, self.CACHE_TIME) cache.set(key, response.data, self.CACHE_TIME)
logger.debug("Set response to cache: {}".format(key)) logger.debug("Set response to cache: {}".format(key))
print(self.CACHE_TIME)
def get(self, request, *args, **kwargs): def get(self, request, *args, **kwargs):
self.cache_policy = request.GET.get('cache_policy', '0') self.cache_policy = request.GET.get('cache_policy', '0')
...@@ -256,7 +256,6 @@ class UserGrantedNodesWithAssetsAsTreeApi(UserPermissionCacheMixin, ListAPIView) ...@@ -256,7 +256,6 @@ class UserGrantedNodesWithAssetsAsTreeApi(UserPermissionCacheMixin, ListAPIView)
return user return user
def get_queryset(self): def get_queryset(self):
print("Call get queryset")
queryset = [] queryset = []
self.show_assets = self.request.query_params.get('show_assets', '1') == '1' self.show_assets = self.request.query_params.get('show_assets', '1') == '1'
self.system_user_id = self.request.query_params.get('system_user') self.system_user_id = self.request.query_params.get('system_user')
......
...@@ -145,7 +145,7 @@ function initTree() { ...@@ -145,7 +145,7 @@ function initTree() {
$(document).ready(function () { $(document).ready(function () {
initTree(); initTree();
{#initTable();#} initTable();
}); });
</script> </script>
{% endblock %} {% endblock %}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment