Skip to content

Commit 5eb58a4

Browse files
committed
[WIP] Issue phpredis#1894
Add RedisSentinel::myid command
1 parent 656dd5f commit 5eb58a4

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

redis_sentinel.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ zend_function_entry redis_sentinel_functions[] = {
4040
PHP_ME(RedisSentinel, getMasterAddrByName, arginfo_value, ZEND_ACC_PUBLIC)
4141
PHP_ME(RedisSentinel, master, arginfo_value, ZEND_ACC_PUBLIC)
4242
PHP_ME(RedisSentinel, masters, arginfo_void, ZEND_ACC_PUBLIC)
43+
PHP_ME(RedisSentinel, myid, arginfo_void, ZEND_ACC_PUBLIC)
4344
PHP_ME(RedisSentinel, ping, arginfo_void, ZEND_ACC_PUBLIC)
4445
PHP_ME(RedisSentinel, reset, arginfo_value, ZEND_ACC_PUBLIC)
4546
PHP_ME(RedisSentinel, sentinels, arginfo_value, ZEND_ACC_PUBLIC)
@@ -132,6 +133,11 @@ PHP_METHOD(RedisSentinel, masters)
132133
REDIS_PROCESS_KW_CMD("masters", redis_sentinel_cmd, sentinel_mbulk_reply_zipped_assoc);
133134
}
134135

136+
PHP_METHOD(RedisSentinel, myid)
137+
{
138+
REDIS_PROCESS_KW_CMD("myid", redis_sentinel_cmd, redis_string_response);
139+
}
140+
135141
PHP_METHOD(RedisSentinel, ping)
136142
{
137143
REDIS_PROCESS_KW_CMD("PING", redis_empty_cmd, redis_boolean_response);

redis_sentinel.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ PHP_METHOD(RedisSentinel, flushconfig);
1212
PHP_METHOD(RedisSentinel, getMasterAddrByName);
1313
PHP_METHOD(RedisSentinel, master);
1414
PHP_METHOD(RedisSentinel, masters);
15+
PHP_METHOD(RedisSentinel, myid);
1516
PHP_METHOD(RedisSentinel, ping);
1617
PHP_METHOD(RedisSentinel, reset);
1718
PHP_METHOD(RedisSentinel, sentinels);

tests/RedisSentinelTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,17 @@ public function testMasters()
8383
}
8484
}
8585

86+
public function testMyid()
87+
{
88+
// Only available since 6.2.0
89+
if (version_compare($this->version, '6.2.0') < 0) {
90+
$this->markTestSkipped();
91+
return;
92+
}
93+
$result = $this->sentinel->myid();
94+
$this->assertTrue(is_string($result));
95+
}
96+
8697
public function testPing()
8798
{
8899
$this->assertTrue($this->sentinel->ping());

0 commit comments

Comments
 (0)