PluginProbe ʕ •ᴥ•ʔ
Hostinger Reach – AI-Powered Email Marketing for WordPress / 1.7.0
Hostinger Reach – AI-Powered Email Marketing for WordPress v1.7.0
1.7.2 1.7.1 1.7.0 1.6.0 1.5.9 1.5.8 1.5.7 1.5.6 1.5.5 1.5.4 1.5.3 1.5.2 1.5.1 1.5.0 1.4.12 1.4.11 1.4.10 1.4.9 1.4.8 1.4.7 trunk 1.0.1 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.1.1 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6
hostinger-reach / vendor / woocommerce / action-scheduler / classes / abstracts / ActionScheduler_Lock.php
hostinger-reach / vendor / woocommerce / action-scheduler / classes / abstracts Last commit date
ActionScheduler.php 9 months ago ActionScheduler_Abstract_ListTable.php 9 months ago ActionScheduler_Abstract_QueueRunner.php 9 months ago ActionScheduler_Abstract_RecurringSchedule.php 9 months ago ActionScheduler_Abstract_Schedule.php 9 months ago ActionScheduler_Abstract_Schema.php 9 months ago ActionScheduler_Lock.php 9 months ago ActionScheduler_Logger.php 9 months ago ActionScheduler_Store.php 9 months ago ActionScheduler_TimezoneHelper.php 9 months ago ActionScheduler_WPCLI_Command.php 9 months ago
ActionScheduler_Lock.php
75 lines
1 <?php
2
3 /**
4 * Abstract class for setting a basic lock to throttle some action.
5 *
6 * Class ActionScheduler_Lock
7 */
8 abstract class ActionScheduler_Lock {
9
10 /**
11 * Instance.
12 *
13 * @var ActionScheduler_Lock
14 */
15 private static $locker = null;
16
17 /**
18 * Duration of lock.
19 *
20 * @var int
21 */
22 protected static $lock_duration = MINUTE_IN_SECONDS;
23
24 /**
25 * Check if a lock is set for a given lock type.
26 *
27 * @param string $lock_type A string to identify different lock types.
28 * @return bool
29 */
30 public function is_locked( $lock_type ) {
31 return ( $this->get_expiration( $lock_type ) >= time() );
32 }
33
34 /**
35 * Set a lock.
36 *
37 * To prevent race conditions, implementations should avoid setting the lock if the lock is already held.
38 *
39 * @param string $lock_type A string to identify different lock types.
40 * @return bool
41 */
42 abstract public function set( $lock_type );
43
44 /**
45 * If a lock is set, return the timestamp it was set to expiry.
46 *
47 * @param string $lock_type A string to identify different lock types.
48 * @return bool|int False if no lock is set, otherwise the timestamp for when the lock is set to expire.
49 */
50 abstract public function get_expiration( $lock_type );
51
52 /**
53 * Get the amount of time to set for a given lock. 60 seconds by default.
54 *
55 * @param string $lock_type A string to identify different lock types.
56 * @return int
57 */
58 protected function get_duration( $lock_type ) {
59 return apply_filters( 'action_scheduler_lock_duration', self::$lock_duration, $lock_type );
60 }
61
62 /**
63 * Get instance.
64 *
65 * @return ActionScheduler_Lock
66 */
67 public static function instance() {
68 if ( empty( self::$locker ) ) {
69 $class = apply_filters( 'action_scheduler_lock_class', 'ActionScheduler_OptionLock' );
70 self::$locker = new $class();
71 }
72 return self::$locker;
73 }
74 }
75