mirror of
https://github.com/ChuckBuilds/LEDMatrix.git
synced 2026-10-06 15:25:08 +00:00
fix(cache): skip rewriting unchanged data saved through CacheManager.set
DiskCache.set skipped a payload identical to the last one written for the key, but CacheManager.set stamps every record with time.time(), so the payload always differed and the skip never fired: unchanged API data was rewritten to the SD card on every plugin update cycle. Header-first records are now compared without their timestamp (the digest also carries the content length, since a collision is now a missed write). A skipped write moves the file's mtime to the skipped record's timestamp, and a real write sets it to the embedded one, so only a skip moves it forward. DiskCache.get, including the header fast path, treats such a record as fresh from the later of the two and returns that time as the record's timestamp. The skip also checks the file is still the one this process wrote (inode and size), so a file another process replaced is rewritten. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -19,6 +19,18 @@ accepts both, but the store flags the old spelling as deprecated
|
||||
|
||||
## Unreleased
|
||||
|
||||
### Fixes
|
||||
|
||||
- Re-saving unchanged data through `CacheManager.set` no longer rewrites its
|
||||
cache file. The disk cache already skipped a payload identical to the last
|
||||
one written, but `set()` stamps every record with the current time, so the
|
||||
skip never fired and every plugin rewrote its unchanged API data to the SD
|
||||
card on every update cycle. Records are now compared without that
|
||||
timestamp, and a skipped write moves the file's mtime to it instead; reads
|
||||
treat a record as fresh from the later of the two, so it expires exactly
|
||||
when the rewrite would have. Changed data or a changed `ttl` still writes,
|
||||
and so does a file another process has replaced since.
|
||||
|
||||
## 3.7.0
|
||||
|
||||
Sports consolidation stage 3 (#672). No behaviour change: nothing in core
|
||||
|
||||
Reference in New Issue
Block a user