Skip to content

Commit

Permalink
tweaks after local testing
Browse files Browse the repository at this point in the history
  • Loading branch information
DGaffney committed Jun 20, 2024
1 parent bb6080e commit 5f59278
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions lib/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,6 @@ def set_cached_result(content_hash: str, result: Any, ttl: int = DEFAULT_TTL) ->
result (Any): The result to cache.
ttl (int): Time-to-live for the cache in seconds. Default is 86400 seconds (24 hours).
"""
client = Cache.get_client()
client.setex(content_hash, ttl, json.dumps(result))
if content_hash:
client = Cache.get_client()
client.setex(content_hash, ttl, json.dumps(result))
2 changes: 1 addition & 1 deletion lib/model/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def get_response(self, message: schemas.Message) -> schemas.GenericItem:
result = Cache.get_cached_result(message.body.content_hash)
if not result:
result = self.process(message)
Cache.set_cached_result(message.body.content_hash, message.body.result)
Cache.set_cached_result(message.body.content_hash, result)
return result

def respond(self, messages: Union[List[schemas.Message], schemas.Message]) -> List[schemas.Message]:
Expand Down

0 comments on commit 5f59278

Please sign in to comment.