better cache key

This commit is contained in:
j 2016-01-22 13:54:58 +05:30
parent b31e73c740
commit d5b9697c44

View file

@ -44,7 +44,11 @@ def find(data):
if 'group' in q: if 'group' in q:
names = {} names = {}
groups = {} groups = {}
key = 'group:' + hashlib.sha1(json.dumps(data).encode('utf-8')).hexdigest() _keydata = data.copy()
for key in ('range', 'position'):
if key in _keydata:
del _keydata[key]
key = 'group:' + hashlib.sha1(json.dumps(_keydata).encode('utf-8')).hexdigest()
g = state.cache.get(key) g = state.cache.get(key)
if g is None: if g is None:
items = q['qs'].options(load_only('id')) items = q['qs'].options(load_only('id'))