BuyupCapLock
\Benecaster\Membership\BuyupCapLock
Serializes capped buy-up purchases through MySQL advisory locks to prevent concurrent purchases from racing past the subscriber cap. Ships in feature/membership-launch-cleanup. Only capped buy-ups (subscriber_cap > 0) use this lock — uncapped buy-ups bypass it entirely. Lock name format: {$wpdb->prefix}benecaster_buyup_cap_{$buyup_id}. Consumers must pair acquire() and release() in a try/finally block to prevent lock leaks.
Methods
| Method | Visibility | Since | Description |
|---|---|---|---|
acquire( int $buyup_id ): bool |
Public | — | Acquires the advisory lock via SELECT GET_LOCK(...) with a 5-second timeout. Returns true on success, false when the lock cannot be obtained within the timeout. |
release( int $buyup_id ): void |
Public | — | Releases the advisory lock via SELECT RELEASE_LOCK(...). Safe to call unconditionally — calling release() when the lock was never acquired is a no-op. |