A
A
Albert Ushakov2019-12-18 22:42:04
PHP
Albert Ushakov, 2019-12-18 22:42:04

How to correctly implement automatic php tasks on the server side?

On a simple example.
The usual clicker on the site with conditions.
A person buys an improvement and after, every minute in the database should add to its old value, a new one (After is used for the top, that is, adding this data only when the user logs in is not suitable).
That is, there must be a condition in this task.
Question. How to implement similar functionality with minimal loads.
Since cron will enter data every minute and if there are a lot of players, then the base will simply fall. Perhaps there is some kind of alternative on the php side or in the very construction of the task ...
How is this generally implemented on sites?
I can't find it on the net. Everyone writes cron and that's it.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
L
latush, 2019-12-18
@fuck_ask

> every minute in the database should add to its old value, store
the time of the last access in the database and before issuing the result, add the required amount.

S
Stalker_RED, 2019-12-18
@Stalker_RED

I have a great plan. So that this addition does not consume resources, I suggest not to do it at all.
Instead, write down the date of purchase of the improvement, and when the user wants to take a look at his number, simply calculate the current value using the formula using the formula.
Type

базовое_значение + (прошедшее_время * значение_бонуса)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question