mongodb - Mongo Data not expiring -


i'm trying insert record in mongo expires in sometime.

getmessagescollection().ensureindex(new basicdbobject("createdat", 1), new basicdbobject("expireafterseconds", 10)); 

i insert data this

map map = new hashmap(); map.put("_id", mongomessage.getobjectid()); // other code map.put("createdat", new date()); getmessagescollection().insert(converttodbobject(map)) 

the field createdat date , before inserting object looks this

{ "_id" : "551bf9b72bea951ecf53fc5f" , "createdat" : { "$date" : "2015-04-01t09:59:19.723z"} , ...} 

but record not getting deleted. can tell me i'm doing wrong?

looks you're incorrectly creating date.

check out how it's done here

date = new date(); basicdbobject time = new basicdbobject("ts", now); 

Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -