Skip to content

Commit

Permalink
fix: Fix caching mechanisms again
Browse files Browse the repository at this point in the history
  • Loading branch information
seriaati committed Mar 3, 2024
1 parent 38dc2f8 commit b239716
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/hoyo/enka_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ def _update_cache_with_live_data(self, cache: EnkaCache, live_data: "ShowcaseRes
live_character_ids: list[int] = []
for character in live_data.characters:
live_character_ids.append(character.id)
cache.extras.get(str(character.id), {}).update(live_chara_data)
if str(character.id) not in cache.extras:
cache.extras[str(character.id)] = live_chara_data
else:
cache.extras[str(character.id)].update(live_chara_data)

cache_characters_not_in_live: list["Character"] = []

Expand Down
5 changes: 4 additions & 1 deletion src/hoyo/mihomo_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ def _update_cache_with_live_data(
live_character_ids: list[str] = []
for character in live_data.characters:
live_character_ids.append(character.id)
cache.extras.get(character.id, {}).update(live_chara_data)
if character.id not in cache.extras:
cache.extras[character.id] = live_chara_data
else:
cache.extras[character.id].update(live_chara_data)

cache_characters_not_in_live: list["Character"] = []

Expand Down

0 comments on commit b239716

Please sign in to comment.