query( $wpdb->prepare( "UPDATE {$wpdb->postmeta} SET meta_value = meta_value + 1 WHERE post_id = %d AND meta_key = %s", $video_id, $meta_key ) ); if ( ! $updated ) { add_post_meta( $video_id, $meta_key, 1, true ); } else { // The direct UPDATE above bypasses WordPress's object cache, so a // cached get_post_meta() read for this post would still return // the pre-increment value. Clear it so the next read (e.g. the // admin video list's Views/Add-to-cart column) reflects the new // count immediately instead of a stale one. wp_cache_delete( $video_id, 'post_meta' ); } } }