Skip to content

Commit

Permalink
Fixed issue with caching
Browse files Browse the repository at this point in the history
  • Loading branch information
kirgrim committed Oct 23, 2023
1 parent e7ca831 commit dae1bf2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions chat_server/server_utils/cache_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ def get(cls, name: str, cache_type: Type = None, **kwargs):
"""
if not cls.__active_caches.get(name):
if cache_type:
kwargs.setdefault("maxsize", 124)
cls.__active_caches[name] = cache_type(**kwargs)
else:
raise KeyError(f"Missing cache instance under {name}")
Expand Down
6 changes: 3 additions & 3 deletions chat_server/sio.py
Original file line number Diff line number Diff line change
Expand Up @@ -458,9 +458,9 @@ async def request_translate(sid, data):
"sid": sid,
"input_type": input_type,
}
CacheFactory.get("translation_cache", cache_type=LRUCache).put(
key=request_id, value=caching_instance
)
CacheFactory.get("translation_cache", cache_type=LRUCache)[
request_id
] = caching_instance
await sio.emit(
"request_neon_translations",
data={"request_id": request_id, "data": missing_translations},
Expand Down

0 comments on commit dae1bf2

Please sign in to comment.