ContainerProperties.DefaultTimeToLive Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets the default time to live in seconds for item in a container from the Azure Cosmos service.
public int? DefaultTimeToLive { get; set; }
member this.DefaultTimeToLive : Nullable<int> with get, set
Public Property DefaultTimeToLive As Nullable(Of Integer)
Property Value
It is an optional property.
A valid value must be either a nonzero positive timespan or null
.
By default, DefaultTimeToLive is set to null meaning the time to live is turned off for the container.
The unit of measurement is seconds. The maximum allowed value is 2147483647.
Examples
The example below disables time-to-live on a container.
container.DefaultTimeToLive = null;
The example below enables time-to-live on a container. By default, all the items never expire.
container.DefaultTimeToLive = TimeSpan.FromDays(2);
The example below enables time-to-live on a container. By default, the item will expire after 1000 seconds since its last write time.
container.DefaultTimeToLive = TimeSpan.FromSeconds(1000);
Remarks
The DefaultTimeToLive will be applied to all the items in the container as the default time-to-live policy. The individual item could override the default time-to-live policy by setting its time to live.
When the DefaultTimeToLive is null
, the time-to-live will be turned off for the container. It means all the items will never expire. The individual item's time to live will be disregarded.
When the DefaultTimeToLive is '-1', the time-to-live will be turned on for the container. By default, all the items will never expire. The individual item could be given a specific time-to-live value by setting its time to live. The item's time to live will be honored, and the expired items will be deleted in background.
When the DefaultTimeToLive is a nonzero positive integer, the time-to-live will be turned on for the container. And a default time-to-live in seconds will be applied to all the items. A item will be expired after the specified DefaultTimeToLive value in seconds since its last write time.
Applies to
Azure SDK for .NET