master

laravel/framework

Last updated at: 29/12/2023 09:21

LockProvider.php

TLDR

This file defines the LockProvider interface in the Illuminate\Contracts\Cache namespace.

Methods

lock

This method creates a lock instance.

Parameters

  • $name (string): The name of the lock.
  • $seconds (int): The number of seconds the lock should be held for. Default is 0, which means the lock has no expiration.
  • $owner (string|null): The owner identifier of the lock. Default is null, which means there is no owner.

Return Value

  • An instance of Illuminate\Contracts\Cache\Lock.

restoreLock

This method restores a lock instance using the owner identifier.

Parameters

  • $name (string): The name of the lock.
  • $owner (string): The owner identifier of the lock.

Return Value

  • An instance of Illuminate\Contracts\Cache\Lock.
<?php

namespace Illuminate\Contracts\Cache;

interface LockProvider
{
    /**
     * Get a lock instance.
     *
     * @param  string  $name
     * @param  int  $seconds
     * @param  string|null  $owner
     * @return \Illuminate\Contracts\Cache\Lock
     */
    public function lock($name, $seconds = 0, $owner = null);

    /**
     * Restore a lock instance using the owner identifier.
     *
     * @param  string  $name
     * @param  string  $owner
     * @return \Illuminate\Contracts\Cache\Lock
     */
    public function restoreLock($name, $owner);
}