Skip to content

[Lock] Update factory contract #44680

@ro0NL

Description

@ro0NL

Description

LockFactory returns SharedLocksInterface's

public function createLock(string $resource, ?float $ttl = 300.0, bool $autoRelease = true): LockInterface
{
return $this->createLockFromKey(new Key($resource), $ttl, $autoRelease);
}

public function createLockFromKey(Key $key, ?float $ttl = 300.0, bool $autoRelease = true): LockInterface
{
$lock = new Lock($key, $this->store, $ttl, $autoRelease);
$lock->setLogger($this->logger);
return $lock;
}

final class Lock implements SharedLockInterface, LoggerAwareInterface

Should we update the return types?

Also acquireRead() may forward to acquire()

public function acquireRead(bool $blocking = false): bool
{
$this->key->resetLifetime();
try {
if (!$this->store instanceof SharedLockStoreInterface) {
$this->logger->debug('Store does not support ReadLocks, fallback to WriteLock.', ['resource' => $this->key]);
return $this->acquire($blocking);
}

which raises questions about this contract in the first place ... :) perhaps an @method on LockInterface is possible still?

Example

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions