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