So I want to make a loop that keeps checking the database and make action if something has changed.
What i'm trying to make is somewhat like a mute system in mongodb. Where I give records an expiry date of the mute length. Which I already did with creating an index option called expireAfterSeconds
. But my problem is I want to make a python script to keep check if the record has expired with using less memory & cpu resources of making mongodb queries.
I have an idea (inefficient solution) and I think it can work but I think it's inefficient because it uses a lot of mongodb queries. And my solution is to make a while
loop in python that keeps making mongodb queries to check if the record has expired or not.
But is there any other solutions that doesn't use a lot of queries or making a loop? And I'm not that good with event driven loops so can someone suggest me another solution to this or should I just stick to my solution?
Sorry for my bad explanation I hope someone can get it. Thanks.