Timber\Helper::handle_transient_locking PHP Метод

handle_transient_locking() защищенный статический Метод

Does the dirty work of locking the transient, running the callback and unlocking
protected static handle_transient_locking ( string $slug, callable $callback, integer $transient_time, integer $lock_timeout, boolean $force, boolean $enable_transients )
$slug string
$callback callable
$transient_time integer Expiration of transients in seconds
$lock_timeout integer How long (in seconds) to lock the transient to prevent race conditions
$force boolean Force callback to be executed when transient is locked
$enable_transients boolean Force callback to be executed when transient is locked
    protected static function handle_transient_locking($slug, $callback, $transient_time, $lock_timeout, $force, $enable_transients)
    {
        if ($enable_transients && self::_is_transient_locked($slug)) {
            $force = apply_filters('timber_force_transients', $force);
            $force = apply_filters('timber_force_transient_' . $slug, $force);
            if (!$force) {
                //the server is currently executing the process.
                //We're just gonna dump these users. Sorry!
                return false;
            }
            $enable_transients = false;
        }
        // lock timeout shouldn't be higher than 5 seconds, unless
        // remote calls with high timeouts are made here
        if ($enable_transients) {
            self::_lock_transient($slug, $lock_timeout);
        }
        $data = $callback();
        if ($enable_transients) {
            set_transient($slug, $data, $transient_time);
            self::_unlock_transient($slug);
        }
        return $data;
    }