/** * Sets the document's time-to-live value. * <p> * A document's time-to-live value is an optional property. If set, the document expires after the specified number * of seconds since its last write time. The value of this property should be one of the following: * <p> * null - indicates the time-to-live value for this document inherits from the parent collection's default time-to-live value. * <p> * nonzero positive integer - indicates the number of seconds before the document expires. It overrides the default time-to-live * value specified on the parent collection, unless the parent collection's default time-to-live is null. * <p> * -1 - indicates the document never expires. It overrides the default time-to-live * value specified on the parent collection, unless the parent collection's default time-to-live is null. * * @param timeToLive the document's time-to-live value in seconds. */ public void setTimeToLive(Integer timeToLive) { // a "null" value is represented as a missing element on the wire. // setting timeToLive to null should remove the property from the property bag. if (timeToLive != null) { super.set(Constants.Properties.TTL, timeToLive); } else if (super.has(Constants.Properties.TTL)) { super.remove(Constants.Properties.TTL); } } }
/** * Sets the collection's default time-to-live value. * <p> * The default time-to-live value on a collection is an optional property. If set, the documents within the collection * expires after the specified number of seconds since their last write time. The value of this property should be one of the following: * <p> * null - indicates evaluation of time-to-live is disabled and documents within the collection will never expire, regardless whether * individual documents have their time-to-live set. * <p> * nonzero positive integer - indicates the default time-to-live value for all documents within the collection. This value can be overridden * by individual documents' time-to-live value. * <p> * -1 - indicates by default all documents within the collection never expire. This value can be overridden by individual documents' * time-to-live value. * * @param timeToLive the default time-to-live value in seconds. */ public void setDefaultTimeToLive(Integer timeToLive) { // a "null" value is represented as a missing element on the wire. // setting timeToLive to null should remove the property from the property bag. if (timeToLive != null) { super.set(Constants.Properties.DEFAULT_TTL, timeToLive); } else if (super.has(Constants.Properties.DEFAULT_TTL)) { super.remove(Constants.Properties.DEFAULT_TTL); } }