[JAVA-637] Create TTL Collection Created: 03/Sep/12  Updated: 11/Sep/19  Resolved: 03/Sep/12

Status: Closed
Project: Java Driver
Component/s: API
Affects Version/s: None
Fix Version/s: None

Type: Task Priority: Major - P3
Reporter: Vineeth Narayanan Assignee: Unassigned
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Windows 7, 64 bit



 Description   

Hi,

I am looking for being able to define the TTL collection using the java driver, is this supported? if so could you point me in the right direction?



 Comments   
Comment by Scott Hernandez (Inactive) [ 05/Sep/12 ]

This is currently not supported, but you can vote for the feature here: SERVER-6700

For now you must remove and add the index back.

Please ask these kinds of questions on the list/group: http://groups.google.com/group/mongodb-user/

Comment by Vineeth Narayanan [ 05/Sep/12 ]

Thanks Jeff.

Could you also let me know what the behaviour should be if I change the "expireAfterSeconds" value between runs? should the value get updated on the existing collection? Is there a way to check the value of the "expireAfterSeconds" via the mongo shell?

Comment by Jeffrey Yemin [ 03/Sep/12 ]

Closing this, but let me know if you have further questions.

Comment by Jeffrey Yemin [ 03/Sep/12 ]

Following the docs at http://docs.mongodb.org/manual/tutorial/expire-data/, you can use this method in the DBCollection class: DBCollection#ensureIndex(final DBObject keys , final DBObject optionsIN). Something like:

myTTLCollection.ensureIndex(new BasicDBObject("someField", 1), new BasicDBObject("expireAfterSeconds", 3600));

Generated at Thu Feb 08 08:52:44 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.