更新 Cosmos DB TTL 容器设置是否会影响旧项目?
Does update Cosmos DB TTL container settings will impact on old items?
我用这段代码更新了我的 cosmos db 容器
var containerResponse = await _cosmosContainer.ReadContainerAsync();
var containerProperties = containerResponse.Resource;
if (containerProperties.DefaultTimeToLive == null)
{
containerProperties.DefaultTimeToLive = 60 * 60 * 24 * 180; // set 180 days default TTL
await _cosmosContainer.ReplaceContainerAsync(containerProperties);
}
更新 Cosmos DB TTL 容器设置是否会影响旧项目?
来自docs,
After you set the TTL at a container or at an item level, Azure Cosmos
DB will automatically remove these items after the time period, since
the time they were last modified.
是的,它会影响旧项目。
我用这段代码更新了我的 cosmos db 容器
var containerResponse = await _cosmosContainer.ReadContainerAsync();
var containerProperties = containerResponse.Resource;
if (containerProperties.DefaultTimeToLive == null)
{
containerProperties.DefaultTimeToLive = 60 * 60 * 24 * 180; // set 180 days default TTL
await _cosmosContainer.ReplaceContainerAsync(containerProperties);
}
更新 Cosmos DB TTL 容器设置是否会影响旧项目?
来自docs,
After you set the TTL at a container or at an item level, Azure Cosmos DB will automatically remove these items after the time period, since the time they were last modified.
是的,它会影响旧项目。