V
V
v-grabko2016-01-16 14:26:20
MySQL
v-grabko, 2016-01-16 14:26:20

What is the best way to implement resource counting?

Hello. Right now I have 2 columns for each resource.
--Max. quantity
-- current quantity
and common column for all
-- resource last recovery
time now I check how much has passed since the last recalculation and if more than 3 minutes have passed then I add n resources to the current quantity.
07a00899858f481e985f03813aad373e.png
Interested in how you can optimize this business? Is there a better algorithm?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
GavriKos, 2016-01-16
@v-grabko

Implement this business on a timer. After all, you know exactly how much time from the current moment you need to increase the amount of resources. Start a timer that will raise the corresponding event. With t.z. performance - gain may be depending on the implementation of the timer. Well, the code will definitely become more beautiful.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question