DocumentCollection.DefaultTimeToLive Property

Definition

Gets the default time to live in seconds for documents in a collection from the Azure DocumentDB database service.

[Newtonsoft.Json.JsonProperty(NullValueHandling=Newtonsoft.Json.NullValueHandling.Ignore, PropertyName="defaultTtl")]
public Nullable<int> DefaultTimeToLive { get; set; }
Property Value

It is an optional property. A valid value must be either a nonzero positive integer, '-1', or null. By default, DefaultTimeToLive is set to null meaning the time to live is turned off for the collection. The unit of measurement is seconds. The maximum allowed value is 2147483647.

Remarks

The DefaultTimeToLive will be applied to all the documents in the collection as the default time-to-live policy. The individual document could override the default time-to-live policy by setting its TimeToLive.

When the DefaultTimeToLive is null, the time-to-live will be turned off for the collection. It means all the documents will never expire. The individual document's TimeToLive will be disregarded.

When the DefaultTimeToLive is '-1', the time-to-live will be turned on for the collection. By default, all the documents will never expire. The individual document could be given a specific time-to-live value by setting its TimeToLive. The document's TimeToLive will be honored, and the expired documents will be deleted in background.

When the DefaultTimeToLive is a nonzero positive integer, the time-to-live will be turned on for the collection. And a default time-to-live in seconds will be applied to all the documents. A document will be expired after the specified DefaultTimeToLive value in seconds since its last write time. The individual document could override the default time-to-live policy by setting its TimeToLive. Please refer to the TimeToLive for more details about evaluating the final time-to-live policy of a document.