Why this matters
Automates storage limitation and provides proof of enforcement.
Implement a scheduled worker to delete or anonymize records past expires_at, with metrics on deletions and failures. Dry-run mode allowed only in non-prod.
Automates storage limitation and provides proof of enforcement.
Side-by-side examples engineers can pattern-match during review.
public void Cleanup(){ / TODO: manual SQL run */ }public class RetentionWorker : BackgroundService {
protected override async Task ExecuteAsync(CancellationToken ct){
while(!ct.IsCancellationRequested){
var n = await db.ExecuteAsync("DELETE FROM events WHERE expires_at <= now()");
metrics.Count("gdpr.retention.deleted", n);
await Task.Delay(TimeSpan.FromHours(24), ct);
}
}
}metrics.Count("gdpr.retention.deleted", n);Console.WriteLine("deleted some"); // no metricsFrom the same buckets as this rule.