-
-
Notifications
You must be signed in to change notification settings - Fork 40
/
Copy pathConnectionCommandsTrait.php
108 lines (95 loc) · 3.03 KB
/
ConnectionCommandsTrait.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
<?php
/**
* This file is part of RedisClient.
* git: https://github.com/cheprasov/php-redis-client
*
* (C) Alexander Cheprasov <acheprasov84@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace RedisClient\Command\Traits\Version6x0;
use RedisClient\Command\Traits\Version5x0\ConnectionCommandsTrait as ConnectionCommandsTraitVersion5x0;
/**
* Connection Commands
* @link http://redis.io/commands#connection
*/
trait ConnectionCommandsTrait {
use ConnectionCommandsTraitVersion5x0;
/**
* CLIENT CACHING YES|NO
* @link https://redis.io/commands/client-caching
*
* @param bool $isEnabled
* @return bool
*/
public function clientCaching($isEnabled) {
return $this->returnCommand(['CLIENT', 'CACHING'], null, [$isEnabled ? 'YES' : 'NO']);
}
/**
* CLIENT GETREDIR
* @link https://redis.io/commands/client-getredir
*
* @return int
*/
public function clientCetredir() {
return $this->returnCommand(['CLIENT', 'GETREDIR'], null, null);
}
/**
* CLIENT TRACKING ON|OFF [REDIRECT client-id] [PREFIX prefix [PREFIX prefix ...]] [BCAST] [OPTIN] [OPTOUT] [NOLOOP]
* @link https://redis.io/commands/client-tracking
*
* @param bool $isEnabled
* @param int|null $redirectClientId
* @param bool|null $bcast
* @param bool|null $optin
* @param bool|null $optout
* @param bool|null $noloop
* @param string|string[]|null $prefixes
* @return int
*/
public function clientTracking($isEnabled, $redirectClientId = null, $prefixes = null, $bcast = null, $optin = null, $optout = null, $noloop = null) {
$params = [$isEnabled ? 'YES' : 'NO'];
if (isset($redirectClientId)) {
$params[] = ['REDIRECT', $redirectClientId];
}
if (isset($prefixes)) {
foreach ($prefixes as $prefix) {
$params[] = ['PREFIX', $prefix];
}
}
if ($bcast) {
$params[] = 'BCAST';
}
if ($optin) {
$params[] = 'OPTIN';
}
if ($optout) {
$params[] = 'OPTOUT';
}
if ($noloop) {
$params[] = 'NOLOOP';
}
return $this->returnCommand(['CLIENT', 'TRACKING'], null, $params);
}
/**
* HELLO protover [AUTH username password] [SETNAME clientname]
* @link https://redis.io/commands/hello
*
* @param int $protover
* @param string|null username
* @param string|null password
* @param string|null $clientName
* @return int
*/
public function hello($protover, $username = null, $password = null, $clientName = null) {
$params = [$protover];
if ($username && $password) {
$params[] = ['AUTH', $username, $password];
}
if (isset($clientName)) {
$params[] = ['SETNAME', $clientName];
}
return $this->returnCommand(['HELLO'], null, $params);
}
}