lock cache key during update
This commit is contained in:
parent
a026d42428
commit
75afa33a6e
3 changed files with 17 additions and 2 deletions
|
|
@ -3,7 +3,6 @@
|
|||
import json
|
||||
import hashlib
|
||||
import os
|
||||
import unicodedata
|
||||
|
||||
from sqlalchemy.orm import load_only
|
||||
from sqlalchemy.sql.expression import text
|
||||
|
|
@ -52,11 +51,13 @@ def find(data):
|
|||
key = 'group:' + hashlib.sha1(json.dumps(_keydata, sort_keys=True).encode('utf-8')).hexdigest()
|
||||
g = state.cache.get(key)
|
||||
if g is None:
|
||||
state.cache.lock(key)
|
||||
items = q['qs'].options(load_only('id'))
|
||||
qs = models.Find.query.filter_by(key=q['group'])
|
||||
if items.first():
|
||||
qs = qs.filter(models.Find.item_id.in_(items))
|
||||
for f in qs.values('value', 'findvalue', 'sortvalue'):
|
||||
values = list(qs.values('value', 'findvalue', 'sortvalue'))
|
||||
for f in values:
|
||||
value = f[0]
|
||||
findvalue = f[1]
|
||||
sortvalue = f[2]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue