简体   繁体   中英

Update a circular array in MongoDB with Java

我已经创建了此类以创建整数的循环缓冲区,我需要将其编写为可用于mongodb,我使用增量和设置来完成添加,但是我不知道如何在不下载和不创建的情况下创建remove方法。重新上传所有数组,难道没有更有效的方法来保持原子性吗?

For the "add" action, you can use the $push operator with $slice modifier when you do the update in MongoDB, see here .

For the "remove" action you can use the $pull operator, see here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM