سؤال

Do we have some way to mark index with expireAfterSeconds property as infinite. I want to do this in order not to be forced to drop index later, and just change TTL using collMod. Or maybe we have some maximum value for expireAfterSeconds property? What do you think?

هل كانت مفيدة؟

المحلول

No, you can't. But you can set it to a very high value like 100 years (about 3.000.000.000 seconds).

Alternatively you could abandon the build-in TTL index mechanism and replicate the functionality on the client-side. MongoDBs TTL is quite primitive. All it does is call db.collection.remove({date:{$lt: new Date() - ttl }) at regular intervals. Replicating this on the application-side is often not really much work.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top