sure, it (it = my code) works - but not very efficiently 
no, I couldn’t make TTL work from within Meteor…
sure, it (it = my code) works - but not very efficiently 
no, I couldn’t make TTL work from within Meteor…
What do you mean by that exactly? I’ve used that technique successfully before.
well, I think polling the DB is unnecessary, and that I can get the same result with, for example, TTL in Mongo. I imagine that would be more efficient.
Awesome that you’ve done this before - do you have any advice on improving my code?
I’m not sure if there’s other area’s of improvement - Haven’t put much thought into it yet, and haven’t tested how performant it is either, so… 
Ah - I thought you were saying that using MongoDB’s TTL didn’t work from Meteor.
wauw, I completely misunderstood:
I couldn’t make it work last night - I did it like this:
example._ensureIndex({expireAt:1},{expireAfterSeconds:0})
That value of 0 for expireAfterSeconds is for use when expiring at a particular clock time (which I haven’t tried). Using a non-zero value (relative time) works fine though - so you may still be right
.
Yeah - I’ll pull up some code now, so we can get to the bottom of this 
const ttl = new Mongo.Collection('ttl')
ttl._ensureIndex({expireAt:1}, {expireAfterSeconds:5})
Meteor.setInterval(() => {
ttl.insert({expireAt:new Date()})
}, 10000)
The above doesn’t work
I’ll try and hack at it some more with different settings…
Well, I’ve just tried my own experiment with values of 0 and non-0 and both work fine!
so if you copy/paste my code it works for you, or did you do something differently? 
Different.
So, I added this in a server/ folder (my Coll = new Mongo.Collection('coll'); is in a lib/ folder):
Meteor.startup(function() {
if (Coll.find().count() === 0) {
Coll._ensureIndex({expireAt:1},{expireAfterSeconds:0});
const now = new Date();
const later = new Date(now.valueOf() + 60000);
Coll.insert({name:'bob', createdAt:now, expireAt:later});
}
});
and used meteor mongo to watch the collection:
db.coll.find().pretty()
(yes, I kept clicking on that!).
Sure enough, at the appointed time the document had gone. Similarly for a non-zero value.
In recent times I am testing this package and I have to say that it is really well done!
for horizontal scaling the author advise to use it:
meteor-multiple-instances-status