Sitelet https://github.com/leemayi/phpredis/commit/dc57c5ed80bb4ed303d71a0648853d03188b7c1e
Skip to content

Commit dc57c5e

Browse files
committed
Added info()
1 parent 012c062 commit dc57c5e

3 files changed

Lines changed: 36 additions & 0 deletions

File tree

‎redis_array.c‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ zend_function_entry redis_array_functions[] = {
2525

2626
PHP_ME(RedisArray, _hosts, NULL, ZEND_ACC_PUBLIC)
2727
PHP_ME(RedisArray, _target, NULL, ZEND_ACC_PUBLIC)
28+
29+
PHP_ME(RedisArray, info, NULL, ZEND_ACC_PUBLIC)
2830
{NULL, NULL, NULL}
2931
};
3032

@@ -409,3 +411,34 @@ PHP_METHOD(RedisArray, _target)
409411
RETURN_NULL();
410412
}
411413
}
414+
415+
PHP_METHOD(RedisArray, info)
416+
{
417+
zval *object, z_fun, *z_tmp;
418+
int i;
419+
RedisArray *ra;
420+
421+
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O",
422+
&object, redis_array_ce) == FAILURE) {
423+
RETURN_FALSE;
424+
}
425+
426+
if (redis_array_get(object, &ra TSRMLS_CC) < 0) {
427+
RETURN_FALSE;
428+
}
429+
430+
/* prepare call */
431+
ZVAL_STRING(&z_fun, "INFO", 0);
432+
433+
array_init(return_value);
434+
for(i = 0; i < ra->count; ++i) {
435+
436+
MAKE_STD_ZVAL(z_tmp);
437+
438+
/* Call each node in turn */
439+
call_user_function(&redis_ce->function_table, &ra->redis[i],
440+
&z_fun, z_tmp, 0, NULL TSRMLS_CC);
441+
442+
add_assoc_zval(return_value, ra->hosts[i], z_tmp);
443+
}
444+
}

‎redis_array.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ PHP_METHOD(RedisArray, __construct);
1111
PHP_METHOD(RedisArray, __call);
1212
PHP_METHOD(RedisArray, _hosts);
1313
PHP_METHOD(RedisArray, _target);
14+
PHP_METHOD(RedisArray, info);
1415

1516

1617
typedef struct RedisArray_ {

‎tests/array-test.php‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,6 @@
1919
var_dump($ra->_hosts());
2020
var_dump($ra->_target('hello'));
2121

22+
var_dump($ra->info());
23+
2224
?>

0 commit comments

Comments
 (0)