mirror of
https://github.com/zarzet/SpotiFLAC-Mobile.git
synced 2026-11-21 20:00:49 +01:00
flutter_cache_manager's JsonCacheInfoRepository re-encodes and rewrites the whole index on the UI isolate for every touch, insert and delete, and scans every entry per lookup. A scroll that shows covers touches one entry per cover, so it keeps a chain of full rewrites going. CoverCacheInfoRepository keeps the same file and JSON format (rows in id order, the same bytes for the same rows, the same .tmp and rename), so older and newer builds read each other's index. It reads the file in a worker isolate, looks entries up by key, keeps each row's encoded JSON until the row changes, and saves 1 s after an insert, delete or content update and 30 s after a touch, or at once on flush and close. Host numbers (JIT, test mode): a scroll over 200 cached covers in a 600-entry index rewrote the index 160 times (about 96,000 rows encoded); now it writes nothing until the flush, which writes once and encodes the 200 touched rows. 20 inserts: 20 writes, now 1. A full rewrite of 1,000 rows held the UI isolate 2.5 to 3.5 ms; a save now takes 0.1 to 0.4 ms there. Opening a 1,000-entry index held it 3 to 6 ms, now under 1 ms. 1,000 lookups took 6.4 ms at 20 entries, 15.6 ms at 1,000 and 450 ms at 20,000; now about 3 ms at every size.