My first post on the forum so hopefully in the right place.
I have a requirement to track which logged in users have viewed which posts (the latest 50 users per post max). I'm thinking one way to do this is to create/update entries in the wp_postmeta table whenever a post is viewed, however i'm struggling getting my mind round how to prevent concurrent update issues.
In order to limit the database entries for each post to the last 50, i would need to get the postmeta before updating it, search for the oldest entry, delete it, and replace it with the details of the latest visit (current_user name and date).
The issue (in my mind anyway) is how to prevent the postmeta data for a post being retrieved concurrently should two or more users visit a post at the same time. The risk is that the original postmeta data would be processed twice and the new postmeta entry would only reflect one of those visits.
Hope that makes sense, and if anyone has any thoughts (or possible other approaches) would be great to hear them.