H
H
HPositron2021-12-08 22:14:53
PHP
HPositron, 2021-12-08 22:14:53

How to implement the accrual of points to the user in real time?

How on the LAMP stack (possibly with memcached) to implement the accrual of points to the user with a certain frequency, let's say every minute, provided that the time count should be done on the server side (so that the client cannot wind up points for himself), and the accrual of points should be displayed to the user on the web -page without reloading it? What solutions can exist and which of them will load the server less?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
ThunderCat, 2021-12-08
@HPositron

If accrual should occur every minute, then you don’t need to do anything, write down the date and time of the start of accrual, and then simply calculate the number of minutes elapsed since the start of accrual. On the frontend, you get this figure at the time of requesting data from the server, then add 1 point every minute using Javascript at an interval. When reloading the page, do the same, transfer the number of minutes from the server and again add 1 point every minute. It is absolutely not necessary to go to the server for this.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question