I was wondering how to approach a building que of a weapon, building or something similar. What i want is to have the option for the player to craft items and later on buildings. The crafting would take time to complete.
What i can do is for each type that can be crafted is create a new table for it that links the userID, itemID/buildingID, and the time on finish. Then do a ajax que every 1 or 2 seconds and add the building if the time condition is met.
Problem is, this AJAX request will find 99,99999% of the time that there are no items/buildings in the que and so it's a waste of resources to do a DB query every second for each player.
Also i would like to update the DB even if the user is logged out. The building should be completed at a certain time because a building can have influence on other players. For my approach, this would mean i have to make an even heavier query for each player every second.
All this is very common in browser games but i can't seem to find any info about this. Any tips on this subject or a redirection on some good info for it is really appreciated.
I think i found a solution witht the help of another forum. I should not do a query every second but only when needed. For example when the page loads make a timer that activates the update/insert query when the time is finished or already passed.
But i still like to hear it if you would take a different approach.