Add RedisSentinel::myid command
This commit is contained in:
Pavlo Yatsukhnenko
2021-02-20 23:10:29 +02:00
parent 656dd5fe5b
commit 5eb58a4c79
3 changed files with 18 additions and 0 deletions

View File

@@ -40,6 +40,7 @@ zend_function_entry redis_sentinel_functions[] = {
PHP_ME(RedisSentinel, getMasterAddrByName, arginfo_value, ZEND_ACC_PUBLIC)
PHP_ME(RedisSentinel, master, arginfo_value, ZEND_ACC_PUBLIC)
PHP_ME(RedisSentinel, masters, arginfo_void, ZEND_ACC_PUBLIC)
PHP_ME(RedisSentinel, myid, arginfo_void, ZEND_ACC_PUBLIC)
PHP_ME(RedisSentinel, ping, arginfo_void, ZEND_ACC_PUBLIC)
PHP_ME(RedisSentinel, reset, arginfo_value, ZEND_ACC_PUBLIC)
PHP_ME(RedisSentinel, sentinels, arginfo_value, ZEND_ACC_PUBLIC)
@@ -132,6 +133,11 @@ PHP_METHOD(RedisSentinel, masters)
REDIS_PROCESS_KW_CMD("masters", redis_sentinel_cmd, sentinel_mbulk_reply_zipped_assoc);
}
PHP_METHOD(RedisSentinel, myid)
{
REDIS_PROCESS_KW_CMD("myid", redis_sentinel_cmd, redis_string_response);
}
PHP_METHOD(RedisSentinel, ping)
{
REDIS_PROCESS_KW_CMD("PING", redis_empty_cmd, redis_boolean_response);

View File

@@ -12,6 +12,7 @@ PHP_METHOD(RedisSentinel, flushconfig);
PHP_METHOD(RedisSentinel, getMasterAddrByName);
PHP_METHOD(RedisSentinel, master);
PHP_METHOD(RedisSentinel, masters);
PHP_METHOD(RedisSentinel, myid);
PHP_METHOD(RedisSentinel, ping);
PHP_METHOD(RedisSentinel, reset);
PHP_METHOD(RedisSentinel, sentinels);

View File

@@ -83,6 +83,17 @@ class Redis_Sentinel_Test extends TestSuite
}
}
public function testMyid()
{
// Only available since 6.2.0
if (version_compare($this->version, '6.2.0') < 0) {
$this->markTestSkipped();
return;
}
$result = $this->sentinel->myid();
$this->assertTrue(is_string($result));
}
public function testPing()
{
$this->assertTrue($this->sentinel->ping());