chg: [api/md5] data sources with MD5 only hashes

This commit is contained in:
Alexandre Dulaunoy 2021-09-01 19:37:21 +02:00
parent 5f93d3e7ab
commit fe04f1e7dd
Signed by: adulau
GPG key ID: 09E2CD4944E6CBCD

View file

@ -82,7 +82,7 @@ class lookup(Resource):
ttl = False ttl = False
if session: if session:
ttl = get_session() ttl = get_session()
if not rdb.exists("l:{}".format(k)): if not (rdb.exists("l:{}".format(k)) or rdb.exists("h:{}".format(k))):
if stats: if stats:
rdb.zincrby("s:nx:md5", score, k) rdb.zincrby("s:nx:md5", score, k)
if stats_pubsub: if stats_pubsub:
@ -100,8 +100,9 @@ class lookup(Resource):
session_key = "session:{}:exist".format(request.headers.get('hashlookup_session')) session_key = "session:{}:exist".format(request.headers.get('hashlookup_session'))
rdb.sadd(session_key, k) rdb.sadd(session_key, k)
rdb.expire(session_key, ttl) rdb.expire(session_key, ttl)
if rdb.exist("h:{}".format(k)): if rdb.exists("h:{}".format(k)):
h = db.hgetall("h:{}".format(k)) h = rdb.hgetall("h:{}".format(k))
sha1 = k
else: else:
sha1 = rdb.get("l:{}".format(k)) sha1 = rdb.get("l:{}".format(k))
h = rdb.hgetall("h:{}".format(sha1)) h = rdb.hgetall("h:{}".format(sha1))