Trabajando para aprovechar el cache el las relaciones

This commit is contained in:
Daniel Cortes
2020-06-09 01:55:12 -04:00
parent 2edca8e255
commit 72bcf94d11
5 changed files with 57 additions and 30 deletions

View File

@@ -4,6 +4,7 @@ import logging
import functools
from django.http import JsonResponse
from django.conf import settings
from pygments import highlight
from pygments.lexers import JsonLexer # pylint: disable=no-name-in-module
@@ -76,3 +77,11 @@ def sanitize_keys(dictionary):
new_key = key.replace('-', '_')
replace_key(dictionary, key, new_key)
return dictionary
def make_key(key, key_prefix=None, version=1):
"""Key generation function for cache"""
if key_prefix is None:
key_prefix = settings.CACHES.get('default').get('KEY_PREFIX')
return ':'.join([key_prefix, str(version), key])