How to limit the number of views a post in Wordpress?

I have a WP template, how can I make it so the user can see post no more than 3 times?
March 23rd 20 at 19:14
2 answers
March 23rd 20 at 19:16
Solution
1) make a meta field to store the data(stored on the user, and in the post and in a separate table in the database)
2) when you open the page and check how many times the user watched the page
3) increase the number of views in the meta field 1

PS I draw your attention that the more people watched a page, the slower it will open
I draw your attention that the more people watched a page, the slower it will open

eh? what is it? - clay commented on March 23rd 20 at 19:19
@clay, get data from DB, process them, put back to DB - Ressie_Stanton62 commented on March 23rd 20 at 19:22
@Ressie_Stanton62, yeah, as soon as we have this feature implemented, we have added 2 queries to the database - receive counter (read) and increment (record). These requests have added a certain overhead, all right. What is the dependence of the speed of page load with this:

the more people viewed a page

? - clay commented on March 23rd 20 at 19:25
March 23rd 20 at 19:18
To create a meta field for the user and store (e.g. in json format) id of posts and hits

Find more questions by tags WordPress