mongodb使用TTL封顶

时间:2016-02-09 09:56:28

标签: mongodb ttl capped-collections

我有一个允许用户与其他用户聊天的应用程序,

我只想在每个会话中存储X条消息,并且每条消息必须在创建后的一个月内删除(TTL)

MongoDB支持使用TTL封顶的集合吗?

文件说: https://docs.mongodb.org/manual/core/capped-collections/#automatically-remove-data-after-a-specified-period-of-time

For additional flexibility when expiring data, consider MongoDB’s TTL indexes, as described in Expire Data from Collections by Setting TTL. These indexes allow you to expire and remove data from normal collections using a special type, based on the value of a date-typed field and a TTL value for the index.

TTL Collections are not compatible with capped collections.

我想不是,那么,还有其他方法可以实现吗?

谢谢

0 个答案:

没有答案