@@ -95,6 +95,44 @@ public PartitionKeyDefinition getPartitionKey() {
95
95
return null ;
96
96
}
97
97
98
+ /**
99
+ * Sets the collection's default time-to-live value.
100
+ * <p>
101
+ * The default time-to-live value on a collection is an optional property. If set, the documents within the collection
102
+ * expires after the specified number of seconds since their last write time. The value of this property should be one of the following:
103
+ * null - indicates evaluation of time-to-live is disabled and documents within the collection will never expire, regardless whether
104
+ * individual documents have their time-to-live set.
105
+ * nonzero positive integer - indicates the default time-to-live value for all documents within the collection. This value can be overridden
106
+ * by individual documents' time-to-live value.
107
+ * -1 - indicates by default all documents within the collection never expire. This value can be overridden by individual documents'
108
+ * time-to-live value.
109
+ *
110
+ * @param timeToLive the default time-to-live value in seconds.
111
+ */
112
+ public void setDefaultTimeToLive (Integer timeToLive ) {
113
+ // a "null" value is represented as a missing element on the wire.
114
+ // setting timeToLive to null should remove the property from the property bag.
115
+ if (timeToLive != null ) {
116
+ super .set (Constants .Properties .DEFAULT_TTL , timeToLive );
117
+ }
118
+ else if (super .has (Constants .Properties .DEFAULT_TTL )) {
119
+ super .remove (Constants .Properties .DEFAULT_TTL );
120
+ }
121
+ }
122
+
123
+ /**
124
+ * Gets the collection's default time-to-live value.
125
+ *
126
+ * @return the the default time-to-live value in seconds.
127
+ */
128
+ public Integer getDefaultTimeToLive () {
129
+ if (super .has (Constants .Properties .DEFAULT_TTL )) {
130
+ return super .getInt (Constants .Properties .DEFAULT_TTL );
131
+ }
132
+
133
+ return null ;
134
+ }
135
+
98
136
/**
99
137
* Gets the self-link for documents in a collection.
100
138
*
0 commit comments