Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Properly handle asyncio.gather() call in SemanticCache.aheck #263

Merged
merged 1 commit into from
Jan 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion redisvl/extensions/llmcache/semantic.py
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ async def acheck(
cache_search_results, return_fields # type: ignore
)
# Extend TTL on keys
asyncio.gather(*[self._async_refresh_ttl(key) for key in redis_keys])
await asyncio.gather(*[self._async_refresh_ttl(key) for key in redis_keys])

return cache_hits

Expand Down
6 changes: 3 additions & 3 deletions tests/integration/test_llmcache.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ async def test_async_ttl_expiration(cache_with_ttl, vectorizer):
vector = vectorizer.embed(prompt)

await cache_with_ttl.astore(prompt, response, vector=vector)
sleep(3)
await asyncio.sleep(3)

check_result = await cache_with_ttl.acheck(vector=vector)
assert len(check_result) == 0
Expand Down Expand Up @@ -442,7 +442,7 @@ async def test_async_updating_document(cache):
check_result = await cache.acheck(prompt=prompt, return_fields=["updated_at"])
key = check_result[0]["key"]

sleep(1)
await asyncio.sleep(1)

metadata = {"foo": "bar"}
await cache.aupdate(key=key, metadata=metadata)
Expand Down Expand Up @@ -479,7 +479,7 @@ async def test_async_ttl_expiration_after_update(cache_with_ttl, vectorizer):
assert cache_with_ttl.ttl == 4

await cache_with_ttl.astore(prompt, response, vector=vector)
sleep(5)
await asyncio.sleep(5)

check_result = await cache_with_ttl.acheck(vector=vector)
assert len(check_result) == 0
Expand Down
Loading