1
|
|
|
<?php declare(strict_types=1); |
2
|
|
|
|
3
|
|
|
namespace Shopware\Core\Test\Stub\Redis; |
4
|
|
|
|
5
|
|
|
if (version_compare(phpversion('redis') ?: '0.0.0', '6.0.0', '>=')) { |
6
|
|
|
trait RedisCompatibility |
7
|
|
|
{ |
8
|
|
|
public function connect( |
9
|
|
|
string $host, |
|
|
|
|
10
|
|
|
int $port = 6379, |
|
|
|
|
11
|
|
|
float $timeout = 0, |
|
|
|
|
12
|
|
|
?string $persistent_id = null, |
|
|
|
|
13
|
|
|
int $retry_interval = 0, |
|
|
|
|
14
|
|
|
float $read_timeout = 0, |
|
|
|
|
15
|
|
|
?array $context = null |
|
|
|
|
16
|
|
|
): bool { |
17
|
|
|
return true; |
18
|
|
|
} |
19
|
|
|
|
20
|
|
|
public function isConnected(): bool |
21
|
|
|
{ |
22
|
|
|
return true; |
23
|
|
|
} |
24
|
|
|
|
25
|
|
|
public function get(string $key): mixed |
26
|
|
|
{ |
27
|
|
|
return $this->doGet($key); |
|
|
|
|
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
public function set(string $key, mixed $value, mixed $options = null): \Redis|string|bool |
31
|
|
|
{ |
32
|
|
|
return $this->doSet($key, $value, $options); |
|
|
|
|
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
public function del(array|string $key, string ...$other_keys): \Redis|int|false |
36
|
|
|
{ |
37
|
|
|
return $this->doDel($key, ...$other_keys); |
|
|
|
|
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
public function exists(mixed $key, mixed ...$other_keys): \Redis|int|bool |
41
|
|
|
{ |
42
|
|
|
return $this->doExists($key, ...$other_keys); |
|
|
|
|
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
public function sAdd(string $key, mixed $value, mixed ...$other_values): \Redis|int|false |
46
|
|
|
{ |
47
|
|
|
return $this->doSAdd($key, $value, ...$other_values); |
|
|
|
|
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
public function sMembers(string $key): \Redis|array|false |
51
|
|
|
{ |
52
|
|
|
return $this->doSMembers($key); |
|
|
|
|
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
public function ttl(string $key): \Redis|int|false |
56
|
|
|
{ |
57
|
|
|
return $this->doTtl($key); |
|
|
|
|
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
public function multi(int $value = \Redis::MULTI): \Redis|bool |
|
|
|
|
61
|
|
|
{ |
62
|
|
|
return new RedisMultiWrapper($this); |
|
|
|
|
63
|
|
|
} |
64
|
|
|
} |
65
|
|
|
} else { |
66
|
|
|
trait RedisCompatibility |
67
|
|
|
{ |
68
|
|
|
public function connect( |
69
|
|
|
$host, |
|
|
|
|
70
|
|
|
$port = 6379, |
|
|
|
|
71
|
|
|
$timeout = 0, |
|
|
|
|
72
|
|
|
$persistent_id = null, |
|
|
|
|
73
|
|
|
$retry_interval = 0, |
|
|
|
|
74
|
|
|
$read_timeout = 0, |
|
|
|
|
75
|
|
|
$context = null |
|
|
|
|
76
|
|
|
) { |
77
|
|
|
return true; |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
public function isConnected() |
81
|
|
|
{ |
82
|
|
|
return true; |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
public function get($key) |
86
|
|
|
{ |
87
|
|
|
return $this->doGet($key); |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
public function set($key, $value, $options = 0) |
91
|
|
|
{ |
92
|
|
|
return $this->doSet($key, $value, $options); |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
public function del($key1, ...$otherKeys) |
96
|
|
|
{ |
97
|
|
|
return $this->doDel($key1, ...$otherKeys); |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
public function exists($key, ...$other_keys) |
101
|
|
|
{ |
102
|
|
|
return $this->doExists($key, ...$other_keys); |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
public function sAdd($key, $value, ...$other_values) |
106
|
|
|
{ |
107
|
|
|
return $this->doSAdd($key, $value, ...$other_values); |
108
|
|
|
} |
109
|
|
|
|
110
|
|
|
public function sMembers($key) |
111
|
|
|
{ |
112
|
|
|
return $this->doSMembers($key); |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
public function ttl($key) |
116
|
|
|
{ |
117
|
|
|
return $this->doTtl($key); |
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
public function multi($mode = \Redis::MULTI) |
|
|
|
|
121
|
|
|
{ |
122
|
|
|
return new RedisMultiWrapper($this); |
|
|
|
|
123
|
|
|
} |
124
|
|
|
} |
125
|
|
|
} |
126
|
|
|
|
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.