admin管理员组

文章数量:1384263

I'm building a site in which my logged-in users can "love" and "collect" posts. The number of loves and collects are stored within the post metadata using get_post_meta() and update_post_meta().

However it occured to me that such operations may be subject to race conditions and indeed this was confirmed by a Core Trac Ticket. Unfortunately, the solution povided in that ticket only works for the most trivial of cases (and only for post meta).

Looking at the WordPress Upgrader class, it has methods for creating and releasing locks but upgrading WordPress is, in the grand scheme of things, a rare occurence. Is this a suitable and scalable solution for post meta or will performance suffer?

Are there any other and more scalable solutions? The counts are required to be 100% accurate.

本文标签: custom fieldHow do I Implement Atomic Update of Post Metadata