ReplicaMetadata.CleanupDeletedItems Method
When overridden in a derived class, removes items that are marked as deleted and that are older than the last successful cleanup time.
Namespace: Microsoft.Synchronization.MetadataStorage
Assembly: Microsoft.Synchronization.MetadataStorage (in microsoft.synchronization.metadatastorage.dll)
Syntax
'Declaration
Public MustOverride Function CleanupDeletedItems ( _
timeInterval As TimeSpan _
) As Boolean
'Usage
Dim instance As ReplicaMetadata
Dim timeInterval As TimeSpan
Dim returnValue As Boolean
returnValue = instance.CleanupDeletedItems(timeInterval)
public abstract bool CleanupDeletedItems (
TimeSpan timeInterval
)
public:
virtual bool CleanupDeletedItems (
TimeSpan timeInterval
) abstract
public abstract boolean CleanupDeletedItems (
TimeSpan timeInterval
)
public abstract function CleanupDeletedItems (
timeInterval : TimeSpan
) : boolean
Parameters
- timeInterval
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
true if cleanup was performed; otherwise, false.
Exceptions
Exception type | Condition |
---|---|
The object has been disposed or was not initialized correctly. |
Remarks
This method helps a provider clean up deleted items on a timed schedule. The time interval specified by timeInterval is the minimum age of deleted items that are kept in the metadata store. Because it only cleans up deleted items when timeInterval time has elapsed, CleanupDeletedItems can be called regularly, such as every time that the provider performs change detection. By always keeping deleted items that have been marked as deleted during timeInterval, 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.
Checks the current time against the last successful cleanup time. If the elapsed time is less than timeInterval, no additional action is taken and false is returned.
Removes all deleted items that are older than the last successful cleanup time.
Saves the current time as the last successful cleanup time.
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 timeInterval 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 timeInterval 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
ReplicaMetadata Class
ReplicaMetadata Members
Microsoft.Synchronization.MetadataStorage Namespace