S
S
StynuBlizz2017-07-13 11:47:01
PostgreSQL
StynuBlizz, 2017-07-13 11:47:01

How to make a video view counter?

How to make a video view counter using a database, but so that if several people watched the video at one moment, all these views were taken into account, and there was no such situation that 5 people watched the video at one moment, and because of the time to change the value of views in bd, 5 views counted as one. I know about locks in the database, but they slow down the work at times (in this case, 5 times), especially since the change in the number of views will take place in one transaction with other requests

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
RidgeA, 2017-07-13
@StynuBlizz

store views in redis, for example
It has atomic increment operations.
And in general, if mysql then do something like this
UPDATE table SET count = count + 1

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question