TsgcWSAPIKeyManagerMethods › PurgeExpired

PurgeExpired Method

Removes all keys whose ExpiresAt is in the past.

Syntax

procedure PurgeExpired;

Remarks

Destructive compaction step — permanently deletes every entry with a non-zero ExpiresAt that is already in the past, regardless of status. Unlike the background sweep (which just flips status to kksExpired and fires OnKeyExpired), this call removes the storage row entirely — KeyExists will return False afterwards. Use it from an admin action or a nightly maintenance job to keep the key file small; do not call it before having processed OnKeyExpired events you rely on. Audit entries are kept untouched (they are only pruned by Audit.RetentionDays).

Example

// Nightly maintenance — free storage by compacting expired rows
sgcWSAPIKeyManager1.PurgeExpired;
sgcWSAPIKeyManager1.SaveToFile;

Back to Methods