I am currently faced with the challenge of managing background events.
When a user is temporarily banned, we save the ban expiration in our database to ensure they are unbanned at the right time. However, my current code checks every ban every 10 seconds to see if the user should be unbanned, but I anticipate that this approach will not scale well as the number of users increases.
I have considered caching all bans after the code starts running, but I believe this method is not very efficient and using setTimeout
may not be the best solution.
Is there a way to track all bans and actively send events to trigger more actions in my code?