mirror of
https://github.com/Hopiu/django-cachalot.git
synced 2026-05-09 13:14:44 +00:00
Hashes cache keys for memcached support.
This commit is contained in:
parent
7c5eea8df1
commit
292cbc8bdc
1 changed files with 6 additions and 1 deletions
|
|
@ -3,6 +3,7 @@
|
|||
from __future__ import unicode_literals
|
||||
from collections import defaultdict, Iterable
|
||||
from functools import wraps
|
||||
from hashlib import md5
|
||||
import re
|
||||
|
||||
from django.conf import settings
|
||||
|
|
@ -30,6 +31,10 @@ PATCHED = False
|
|||
MISS_VALUE = '[[Missing cache key]]'
|
||||
|
||||
|
||||
def _get_query_cache_key(compiler):
|
||||
return md5('%s:%s' % compiler.as_sql()).hexdigest()
|
||||
|
||||
|
||||
def _get_tables(query):
|
||||
"""
|
||||
Returns a ``set`` of all database table names used by ``query``.
|
||||
|
|
@ -175,7 +180,7 @@ def _patch_orm_read():
|
|||
return original(compiler, *args, **kwargs)
|
||||
|
||||
try:
|
||||
cache_key = compiler.as_sql()
|
||||
cache_key = _get_query_cache_key(compiler)
|
||||
except EmptyResultSet:
|
||||
return original(compiler, *args, **kwargs)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue