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

Refactor cache system #154

Merged
merged 5 commits into from
May 17, 2024
Merged

Refactor cache system #154

merged 5 commits into from
May 17, 2024

Conversation

tsutaj
Copy link
Owner

@tsutaj tsutaj commented May 16, 2024

Resolves #150

キャッシュ機構をリファクタリング

if Path(self.problemset_dir / "cache.json").exists():
reference_problemset_cache = json.load(
open(self.problemset_dir / "cache.json")
cache = RenderResultCache(self.problemset_dir, output_ext)
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

問題セットのキャッシュファイルは構造が変わるが、許容する

@tsutaj tsutaj changed the title Refactor cache object Refactor cache system May 16, 2024
output_ext=output_ext,
problem_ids=valid_problem_ids,
is_problemset=True,
force_dump=force_dump or has_diff,
Copy link
Owner Author

@tsutaj tsutaj May 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

どれかの問題で差分が発生していたら、problemset が更新される
(以前は cache の中身で判定していたが、判定方法を変更)

cache = self._load_cache()
return self._setup_cache(cache)

def _cleanup(self, cache: dict) -> dict:
Copy link
Owner Author

@tsutaj tsutaj May 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ここで行っているのは、以下の 2 つ

  • 不要になった id を列挙し、キャッシュの辞書から削除
  • 不要になった id に関係あるファイルを列挙し、ファイルを削除

やや非自明で、一応コメントがあるといいかもだけど、これくらいならなくても読める気もする。

@tsutaj tsutaj enabled auto-merge (squash) May 17, 2024 02:05
@tsutaj tsutaj merged commit bccb12f into master May 17, 2024
7 checks passed
@tsutaj tsutaj deleted the 150-refactor-cache branch May 17, 2024 02:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

キャッシュオブジェクトのリファクタリング
1 participant