fix: Always expect a list from srandmember (valkey vs. kvrocks)

More details: https://github.com/apache/kvrocks/issues/2610
pull/965/head
Raphaël Vinot 2024-10-18 21:22:07 +02:00
parent 9bc29ee964
commit 798c5b5699
1 changed files with 3 additions and 2 deletions

View File

@ -320,8 +320,9 @@ class Indexing():
if capture_uuids := self.redis.zrevrange(f'body_hashes|{body_hash}|captures', 0, 0, withscores=False):
capture_uuid = capture_uuids[0]
internal_index = f'capture_indexes|{capture_uuid}'
if urlnode_uuid := self.redis.srandmember(f'{internal_index}|body_hashes|{body_hash}'):
return str(capture_uuid), str(urlnode_uuid)
urlnode_uuid: list[bytes | float | int | str]
if urlnode_uuid := self.redis.srandmember(f'{internal_index}|body_hashes|{body_hash}', 1):
return str(capture_uuid), str(urlnode_uuid[0])
return None
def get_captures_body_hash(self, body_hash: str, most_recent_capture: datetime | None = None,