This class seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate
the same code in three or more different places, we strongly encourage you to
look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.
Loading history...
20
{
21
/**
22
* phpredis connection
23
*
24
* @var
25
*/
26
protected $client;
27
28
/**
29
* @param $client Redis
30
*/
31
public function __construct(Redis $client)
32
{
33
parent::__construct();
34
35
$this->client = $client;
36
}
37
38
/**
39
* @param string $name
40
* @param bool $blocking
41
* @return bool
42
*/
43
protected function getLock($name, $blocking)
44
{
45
if (!$this->client->setnx($name, serialize($this->getLockInformation()))) {
46
return false;
47
}
48
49
return true;
50
}
51
52
/**
53
* Release lock
54
*
55
* @param string $name name of lock
56
* @return bool
57
*/
58
public function releaseLock($name)
59
{
60
if (isset($this->locks[$name]) && $this->client->del($name)) {
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.