キャッシュキーとは?
cache key は、cache エントリの保存と取得に使われる文字列で、通常は lockfile のハッシュや OS と言語のバージョンなど、結果を決定する入力から計算されます。入力が変わると key も変わるため、古いものを再利用せず新しいエントリが作成されます。key を正しく設計することが安全な caching の核心です。
なぜ重要か
関連する入力を省いた key は古く誤った再利用を引き起こし、含めすぎた key は毎回変わるため決してヒットしません。優れた CI の cache は、lockfile のハッシュに環境を加えたものを key とし、しばしば restore-keys をフォールバックとして使うことで、近い一致でも cache を初期化してヒット率を高められます。
関連する概念
- 多くの場合 lockfile のハッシュに環境を加えたもの
- restore-keys はフォールバックの部分一致を提供する
- 出力に影響するすべての入力を含める必要がある
関連ガイド
What Is Cache Hit Ratio?Cache hit ratio is the fraction of cache lookups served from the cache rather than recomputed or refetched, a…
What Is Cache Scope?Cache scope defines the boundary within which a cache entry is shared and reusable, such as per branch, per r…
What Is Cache Eviction?Cache eviction is the removal of entries from a cache to make room or enforce limits, using policies like lea…