Skip to content

Commit

Permalink
Merge pull request #214 from serfend/JxTrade
Browse files Browse the repository at this point in the history
fix[trade]cache data sync
  • Loading branch information
Serfend authored Jun 22, 2023
2 parents f39c164 + 100e6c5 commit 703fa84
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/plugins/jx3/price_goods/lib/GoodsInfoFullExt.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
import copy


def check_cache_integrity(current_cache: dict):
def check_cache_integrity(current_cache: dict, new_data: dict):
# 当前缓存没有缓存品数,应为其缓存
cached_level = 'level' in current_cache
should_update_cache = not cached_level
if not should_update_cache:
return
current_cache['level'] = x.get('Level')
current_cache['level'] = new_data.get('Level')
CACHE_Goods[current_cache['id']] = current_cache
flush_CACHE_Goods()

Expand All @@ -21,10 +21,11 @@ async def from_id(id: str) -> GoodsInfoFull:
cache_data: GoodsInfo = CACHE_Goods.get(id)
if not cache_data is None:
current_cache = cache_data.to_dict()
check_cache_integrity(current_cache, data)

x = copy.deepcopy(current_cache)
x.update(data)
data = x
check_cache_integrity(current_cache)

return GoodsInfoFull(data)

Expand Down

0 comments on commit 703fa84

Please sign in to comment.