Skip to content

Commit

Permalink
Merge pull request #51 from athos-ribeiro/psr-log-3
Browse files Browse the repository at this point in the history
Comply with psr/log 3
  • Loading branch information
Willem Stuursma-Ruwen authored Apr 26, 2022
2 parents 6ff3c37 + e344556 commit 63c1b26
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 22 deletions.
24 changes: 3 additions & 21 deletions classes/mutex/RedisMutex.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use malkusch\lock\exception\LockAcquireException;
use malkusch\lock\exception\LockReleaseException;
use Psr\Log\LoggerAwareInterface;
use Psr\Log\LoggerInterface;
use Psr\Log\LoggerAwareTrait;
use Psr\Log\NullLogger;

/**
Expand All @@ -21,6 +21,8 @@
*/
abstract class RedisMutex extends SpinlockMutex implements LoggerAwareInterface
{
use LoggerAwareTrait;

/**
* @var string The random value token for key identification.
*/
Expand All @@ -31,11 +33,6 @@ abstract class RedisMutex extends SpinlockMutex implements LoggerAwareInterface
*/
private $redisAPIs;

/**
* @var LoggerInterface The logger.
*/
private $logger;

/**
* Sets the Redis APIs.
*
Expand All @@ -53,21 +50,6 @@ public function __construct(array $redisAPIs, string $name, int $timeout = 3)
$this->logger = new NullLogger();
}

/**
* Sets a logger instance on the object
*
* RedLock is a fault tolerant lock algorithm. I.e. it does tolerate
* failing redis connections without breaking. If you want to get notified
* about such events you'll have to provide a logger. Those events will
* be logged as warnings.
*
* @param LoggerInterface $logger The logger.
*/
public function setLogger(LoggerInterface $logger)
{
$this->logger = $logger;
}

protected function acquire(string $key, int $expire): bool
{
// 1. This differs from the specification to avoid an overflow on 32-Bit systems.
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
},
"require": {
"php": "^7.2 || ^8.0",
"psr/log": "^1"
"psr/log": "^1|^2|^3"
},
"require-dev": {
"ext-memcached": "*",
Expand Down

0 comments on commit 63c1b26

Please sign in to comment.