Skip to content

Commit 6117d52

Browse files
committed
Started work on TTL update
1 parent df5c57b commit 6117d52

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

articles/cosmos-db/how-to-time-to-live.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,21 @@ await client.GetDatabase("database").CreateContainerAsync(new ContainerPropertie
7070
});
7171
```
7272

73+
### <a id="dotnet-enable-noexpiry"></a>Java SDK V4 (com.azure.azure-cosmos)
74+
75+
```java
76+
private CosmosAsyncContainer container;
77+
78+
// Create a new container with TTL enabled and without any expiration value
79+
CosmosContainerProperties containerProperties = new CosmosContainerProperties(containerName, "/lastName");
80+
containerProperties.setDefaultTimeToLiveInSeconds(-1);
81+
database.createContainerIfNotExists(containerProperties, 400).flatMap(containerResponse -> {
82+
container = containerResponse.getContainer();
83+
return Mono.empty();
84+
}).block();
85+
```
86+
87+
7388
## Set time to live on a container using SDK
7489

7590
To set the time to live on a container, you need to provide a non-zero positive number that indicates the time period in seconds. Based on the configured TTL value, all items in the container after the last modified timestamp of the item `_ts` are deleted.

0 commit comments

Comments
 (0)