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

resets cache ttl when no arg is passed #181

Merged
merged 1 commit into from
Jul 19, 2024
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: 2 additions & 0 deletions redisvl/extensions/llmcache/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ def set_ttl(self, ttl: Optional[int] = None):
if not isinstance(ttl, int):
raise ValueError(f"TTL must be an integer value, got {ttl}")
self._ttl = int(ttl)
else:
self._ttl = None

def clear(self) -> None:
"""Clear the LLMCache of all keys in the index."""
Expand Down
6 changes: 6 additions & 0 deletions tests/integration/test_llmcache.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ def test_set_ttl(cache):
assert cache.ttl == 5


def test_reset_ttl(cache):
cache.set_ttl(4)
cache.set_ttl()
assert cache.ttl is None


# Test basic store and check functionality
def test_store_and_check(cache, vectorizer):
prompt = "This is a test prompt."
Expand Down
Loading