Skip to content

Commit 2c8bd52

Browse files
branchseerclaude
andcommitted
docs(cache): document key vs value design principle
Key fields create separate entries (reverting a change can hit the old entry). Value fields overwrite the same entry (no need to remember old state). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 06775f8 commit 2c8bd52

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

  • crates/vite_task/src/session/cache

crates/vite_task/src/session/cache/mod.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,16 @@ use super::execute::{
2222

2323
/// Cache lookup key identifying a task's execution configuration.
2424
///
25-
/// Contains the spawn fingerprint (command, env, cwd), input configuration,
26-
/// and glob base directory. Explicit input file hashes are stored in
27-
/// [`CacheEntryValue`] so that changes can be detected and reported.
25+
/// # Key vs value design
26+
///
27+
/// Put a field in the **key** if each distinct value should have its own
28+
/// cache entry (e.g., different env values → different entries, so
29+
/// reverting an env change can still hit the old entry).
30+
///
31+
/// Put a field in the **value** ([`CacheEntryValue`]) if changes should
32+
/// overwrite the existing entry (e.g., input file hashes — there's no
33+
/// reason to keep the old hash around, and storing them in the value
34+
/// lets us report exactly *which file* changed).
2835
#[derive(Debug, Encode, Decode, Serialize, PartialEq, Eq, Clone)]
2936
pub struct CacheEntryKey {
3037
/// The spawn fingerprint (command, args, cwd, envs)

0 commit comments

Comments
 (0)