# HG changeset patch # User durandn # Date 1428939212 -7200 # Node ID fe8782a67fcfdbfd5752ca3f8d26bf70b951d570 # Parent 9f17fdf3b0fc60e4b7f06cb7b544431c0bb1ff9f cache optimisation : no more cache.clear() but 2 "keys sets" for each repository: one for the categories and one for the comments and discussion + corrected slight mistake in macro that messed up with sessions diff -r 9f17fdf3b0fc -r fe8782a67fcf src/catedit/resources.py --- a/src/catedit/resources.py Mon Apr 13 12:37:41 2015 +0200 +++ b/src/catedit/resources.py Mon Apr 13 17:33:32 2015 +0200 @@ -43,6 +43,20 @@ The result of this API function goes into the Flask Cache. """ cache_key = "categoryapi_get_" + repository + "_" + cat_id + + # Maintaining repo cache key list + repo_key = "categories_"+repository+"_keys" + if cache.get(repo_key) is None: + cache.set(repo_key, [cache_key]) + else: + if cache_key not in cache.get(repo_key): + key_list = cache.get(repo_key) + key_list.append(cache_key) + logger.debug(key_list) + cache.set(repo_key, key_list) + + logger.debug("keys in category: "+repo_key+" :"+str(cache.get(repo_key))) + if cache.get(cache_key) is None: rv = None cat_manager_instance = CategoryManager( @@ -118,7 +132,6 @@ session.setdefault("tasks", {}).setdefault(repository, []).append(task.id) session.setdefault("deleted_categories", {})[repository] = {} session.setdefault("modified_categories", {})[repository] = {} - cache.clear() return 204 else: # is the edition occuring on an already modified category? diff -r 9f17fdf3b0fc -r fe8782a67fcf src/catedit/tasks.py --- a/src/catedit/tasks.py Mon Apr 13 12:37:41 2015 +0200 +++ b/src/catedit/tasks.py Mon Apr 13 17:33:32 2015 +0200 @@ -33,7 +33,8 @@ modified_cat_dict=modified_categories, message=message ) - r = requests.post(app.config['BASE_URL']+"/meta/cache-clear") + registry_key = "categories_"+repository+"_keys" + r = requests.post(app.config['BASE_URL']+"/meta/cache-clear/"+registry_key) try: r.raise_for_status() except: diff -r 9f17fdf3b0fc -r fe8782a67fcf src/catedit/templates/macros.html --- a/src/catedit/templates/macros.html Mon Apr 13 12:37:41 2015 +0200 +++ b/src/catedit/templates/macros.html Mon Apr 13 17:33:32 2015 +0200 @@ -94,7 +94,7 @@ {% if cat.state != "deleted" %}