1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace MGDigital\BusQue\Redis\PHPRedis; |
4
|
|
|
|
5
|
|
|
use MGDigital\BusQue\Exception\DriverException; |
6
|
|
|
use MGDigital\BusQue\Redis\RedisAdapterInterface; |
7
|
|
|
|
8
|
|
|
class PHPRedisAdapter implements RedisAdapterInterface |
9
|
|
|
{ |
10
|
|
|
|
11
|
|
|
private $redis; |
12
|
|
|
|
13
|
11 |
|
public function __construct(\Redis $redis) |
14
|
|
|
{ |
15
|
11 |
|
$this->redis = $redis; |
16
|
11 |
|
} |
17
|
|
|
|
18
|
1 |
|
public function bRPopLPush(string $source, string $destination, int $timeout) |
19
|
|
|
{ |
20
|
|
|
return $this->tryCatch(function () use ($source, $destination, $timeout) { |
21
|
1 |
|
return $this->redis->brpoplpush($source, $destination, $timeout); |
22
|
1 |
|
}); |
23
|
|
|
} |
24
|
|
|
|
25
|
1 |
|
public function hGet(string $key, string $field) |
26
|
|
|
{ |
27
|
|
|
return $this->tryCatch(function () use ($key, $field) { |
28
|
1 |
|
return $this->redis->hGet($key, $field); |
29
|
1 |
|
}); |
30
|
|
|
} |
31
|
|
|
|
32
|
1 |
|
public function sAdd(string $key, array $members) |
33
|
|
|
{ |
34
|
|
|
$this->tryCatch(function () use ($key, $members) { |
35
|
1 |
|
$this->redis->sAdd($key, ...$members); |
36
|
1 |
|
}); |
37
|
1 |
|
} |
38
|
|
|
|
39
|
1 |
|
public function sRem(string $key, array $members) |
40
|
|
|
{ |
41
|
|
|
$this->tryCatch(function () use ($key, $members) { |
42
|
1 |
|
$this->redis->sRem($key, ...$members); |
43
|
1 |
|
}); |
44
|
1 |
|
} |
45
|
|
|
|
46
|
1 |
|
public function sIsMember(string $key, string $value): bool |
47
|
|
|
{ |
48
|
|
|
return $this->tryCatch(function () use ($key, $value) { |
49
|
1 |
|
return $this->redis->sIsMember($key, $value); |
50
|
1 |
|
}); |
51
|
|
|
} |
52
|
|
|
|
53
|
1 |
|
public function sMembers(string $key): array |
54
|
|
|
{ |
55
|
|
|
return $this->tryCatch(function () use ($key) { |
56
|
1 |
|
return $this->redis->sMembers($key); |
57
|
1 |
|
}); |
58
|
|
|
} |
59
|
|
|
|
60
|
1 |
|
public function lLen(string $key): int |
61
|
|
|
{ |
62
|
|
|
return $this->tryCatch(function () use ($key) { |
63
|
1 |
|
return $this->redis->lLen($key); |
64
|
1 |
|
}); |
65
|
|
|
} |
66
|
|
|
|
67
|
1 |
|
public function lRange(string $key, int $offset = 0, int $limit = 10): array |
68
|
|
|
{ |
69
|
|
|
return $this->tryCatch(function () use ($key, $offset, $limit) { |
70
|
1 |
|
return $this->redis->lRange($key, $offset, $limit); |
71
|
1 |
|
}); |
72
|
|
|
} |
73
|
|
|
|
74
|
1 |
|
public function zScore(string $key, string $value) |
75
|
|
|
{ |
76
|
|
|
$score = $this->tryCatch(function () use ($key, $value) { |
77
|
1 |
|
return $this->redis->zScore($key, $value); |
78
|
1 |
|
}); |
79
|
1 |
|
return $score === null ? $score : intval($score); |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
public function evalLua(string $lua, array $args) |
83
|
|
|
{ |
84
|
1 |
|
return $this->tryCatch(function () use ($lua, $args) { |
85
|
1 |
|
return $this->redis->evaluate($lua, $args, 0); |
86
|
1 |
|
}); |
87
|
|
|
} |
88
|
|
|
|
89
|
10 |
|
private function tryCatch(callable $callable) |
90
|
|
|
{ |
91
|
|
|
try { |
92
|
10 |
|
return $callable(); |
93
|
10 |
|
} catch (\RedisException $e) { |
|
|
|
|
94
|
10 |
|
throw new DriverException($e->getMessage(), 0, $e); |
95
|
|
|
} |
96
|
|
|
} |
97
|
|
|
} |
98
|
|
|
|
Scrutinizer analyzes your
composer.json
/composer.lock
file if available to determine the classes, and functions that are defined by your dependencies.It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis.