Sdílet prostřednictvím


IReplicaMetadata::CleanupDeletedItems

Removes items that are marked as deleted and that are older than the last successful cleanup time.

HRESULT CleanupDeletedItems(
  ULONGLONG ulTimeIntervalInMilliseconds);

Parameters

  • ulTimeIntervalInMilliseconds
    [in] The minimum age of deleted items to keep in the metadata store. A value of 0 means all deleted items are cleaned up immediately.

Return Value

  • S_OK

  • S_FALSE when no cleanup is performed.

  • E_OUTOFMEMORY

  • SYNC_E_METADATA_ACTIVE_TRANSACTION_REQUIRED when an explicit transaction is not open.

  • SYNC_E_INVALID_OPERATION when an invalid operation occurs.

Remarks

This method helps a provider clean up deleted items on a timed schedule. The time interval specified by ulTimeIntervalInMilliseconds is the minimum age of deleted items that are kept in the metadata store. Because it only cleans up deleted items when ulTimeIntervalInMilliseconds time has elapsed, CleanupDeletedItems can be called regularly, such as every time the provider performs change detection. By always keeping deleted items that have been marked as deleted during ulTimeIntervalInMilliseconds, CleanupDeletedItems helps protect the provider against expensive full enumerations.

The first time CleanupDeletedItems is called, it stores the current time as the last successful cleanup time and takes no other action.

Each successive time CleanupDeletedItems is called, it performs the following steps:

  1. Checks the current time against the last successful cleanup time. If the elapsed time is less than ulTimeIntervalInMilliseconds, no action is taken and S_FALSE is returned.

  2. Removes all deleted items that are older than the last successful cleanup time.

  3. Saves the current time as the last successful cleanup time.

  4. Updates the forgotten knowledge to reflect the deleted items that were removed.

Be aware that CleanupDeletedItems only cleans up items that were marked as deleted before the last successful cleanup time, and not items that have been marked as deleted since the last successful cleanup time. For example, CleanupDeletedItems successfully cleans up items and stores the current time. Twenty-four days later, CleanupDeletedItems is called again with ulTimeIntervalInMilliseconds specified as 20 days. CleanupDeletedItems only removes deleted items that are older than 24 days, because that is when the last successful cleanup was performed. An item that was marked as deleted between 24 and 20 days ago, such as 22 days ago, will not be removed. Any deleted item that is not 20-days old will also not be removed.

Note

Specifying a value of 0 for ulTimeIntervalInMilliseconds is a special case that causes all the deleted items to be removed from the metadata store. This should only be done when a provider is reasonably certain that all other replicas in the synchronization community are synchronized with each other, because removing deleted items too aggressively can cause Sync Framework to perform a full enumeration.

See Also

Reference

IReplicaMetadata Interface