Skip to main content

prune_old_entries

Function prune_old_entries 

Source
pub async fn prune_old_entries(pool: &SqlitePool, days: i64) -> Result<u64>
Expand description

Delete entries whose age exceeds the retention window — the shared cache’s rolling window. “Age” is COALESCE(published, fetched_at) so an UNDATED entry falls back to when it was fetched (never NULL) rather than being treated as infinitely old. entry_state cascades via its ON DELETE CASCADE FK.

After the delete, orphaned entry ids are scrubbed out of every affected feed’s read_cursor exception sets (which have no FK to entries) so the id-sets do not grow without bound and the flushed PDS record never references a vanished entry. The caller (the retention sweep) should follow a non-zero return with reclaim so freed pages return to the OS. days == 0 is a no-op (retention disabled). Returns the number of entry rows deleted.