Commit 70d301a9 authored by David Mendez's avatar David Mendez
Browse files

Merge branch 'staging' into 'master'

Include cache key suffix in memoization

See merge request !68
parents c7d0d08c 8de6f61a
......@@ -6,6 +6,7 @@ from app.visualisation_data.target_classification import go_slim
from app.visualisation_data.target_classification import organism_taxonomy
from app.visualisation_data.target_classification import protein_class
from app.cache import CACHE
from app.cache import make_memoize_cache_key
from app.config import RUN_CONFIG
from app.es_data import es_data
......@@ -44,7 +45,7 @@ def get_in_vivo_assay_classification():
return in_vivo.get_classification_tree()
@CACHE.memoize(timeout=RUN_CONFIG.get('es_proxy_cache_seconds'))
@CACHE.memoize(timeout=RUN_CONFIG.get('es_proxy_cache_seconds'), make_name=make_memoize_cache_key)
def get_database_summary():
"""
:return: the database_summary
......@@ -112,7 +113,7 @@ def entities_records():
}
@CACHE.memoize(timeout=RUN_CONFIG.get('es_proxy_cache_seconds'))
@CACHE.memoize(timeout=RUN_CONFIG.get('es_proxy_cache_seconds'), make_name=make_memoize_cache_key)
def covid_entities_records():
"""
:return: the database_summary
......
......@@ -23,6 +23,17 @@ def fail_proof_get(key):
return None
def make_memoize_cache_key(function_name):
"""
Makes a cache key for the memoized functions
:param function_name: name of the function to memoize
:return: the name of the function including the cache suffix
"""
cache_key = f'{function_name}-{RUN_CONFIG.get("cache_key_suffix")}'
return cache_key
def fail_proof_set(key, value, timeout):
"""
:param key: key to save the item with
......
......@@ -80,7 +80,7 @@ def load_context_index(context_id, id_properties_list, context):
:return:
"""
context_index_key = 'context_index-{}'.format(context_id)
context_index_key = f'context_index-{context_id}-{RUN_CONFIG.get("cache_key_suffix")}'
context_index = cache.fail_proof_get(context_index_key)
if context_index is None:
context_index = {}
......
......@@ -6,6 +6,7 @@ from app import app_logging
from app.es_data import utils
from app.config import RUN_CONFIG
from app.cache import CACHE
from app.cache import make_memoize_cache_key
from utils import dict_property_access
SIMPLE_MAPPINGS = {
......@@ -63,7 +64,7 @@ class EsMappingsError(Exception):
"""Base class for exceptions in the ES Mappings"""
@CACHE.memoize(timeout=RUN_CONFIG.get('es_mappings_cache_seconds'))
@CACHE.memoize(timeout=RUN_CONFIG.get('es_mappings_cache_seconds'), make_name=make_memoize_cache_key)
def get_simplified_property_mapping(index_name, property_id):
"""
:param index_name: index name where the property belongs
......@@ -91,7 +92,7 @@ def get_simplified_property_mapping(index_name, property_id):
return simplified_mapping
@CACHE.memoize(timeout=RUN_CONFIG.get('es_mappings_cache_seconds'))
@CACHE.memoize(timeout=RUN_CONFIG.get('es_mappings_cache_seconds'), make_name=make_memoize_cache_key)
def get_index_mapping(index_name):
"""
:param index_name: name of the index to check
......
......@@ -230,3 +230,7 @@ chembl_drug_warning_by_parent:
report_card_table:
default: ['drug_warning.warning_type', 'drug_warning.warning_class', 'drug_warning.warning_description',
'drug_warning.where', 'drug_warning.warning_refs']
browser_table:
default: [ 'drug_warning.molecule_chembl_id', 'drug_warning.parent_molecule_chembl_id', 'drug_warning.warning_type',
'drug_warning.warning_class', 'drug_warning.warning_description',
'drug_warning.where', 'drug_warning.warning_refs' ]
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