Skip to content

Commit 3edeb29

Browse files
Implements the getMode() command
This introspection function will inform the caller what mode phpredis is in (atomic, pipeline, multi)
1 parent 6f75b0e commit 3edeb29

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

php_redis.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ PHP_METHOD(Redis, getReadTimeout);
211211
PHP_METHOD(Redis, isConnected);
212212
PHP_METHOD(Redis, getPersistentID);
213213
PHP_METHOD(Redis, getAuth);
214-
214+
PHP_METHOD(Redis, getMode);
215215
PHP_METHOD(Redis, command);
216216

217217
#ifdef PHP_WIN32

redis.c

+20-1
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ static zend_function_entry redis_functions[] = {
288288
PHP_ME(Redis, getPersistentID, NULL, ZEND_ACC_PUBLIC)
289289
PHP_ME(Redis, getAuth, NULL, ZEND_ACC_PUBLIC)
290290
PHP_ME(Redis, isConnected, NULL, ZEND_ACC_PUBLIC)
291-
291+
PHP_ME(Redis, getMode, NULL, ZEND_ACC_PUBLIC)
292292
PHP_ME(Redis, wait, NULL, ZEND_ACC_PUBLIC)
293293
PHP_ME(Redis, pubsub, NULL, ZEND_ACC_PUBLIC)
294294

@@ -6947,6 +6947,25 @@ PHP_METHOD(Redis, clearLastError) {
69476947
RETURN_TRUE;
69486948
}
69496949

6950+
/*
6951+
* {{{ proto long Redis::getMode()
6952+
*/
6953+
PHP_METHOD(Redis, getMode) {
6954+
zval *object;
6955+
RedisSock *redis_sock;
6956+
6957+
/* Grab our object */
6958+
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &object, redis_ce) == FAILURE) {
6959+
RETURN_FALSE;
6960+
}
6961+
6962+
/* Grab socket */
6963+
if (redis_sock_get(object, &redis_sock TSRMLS_CC, 0) < 0) {
6964+
RETURN_FALSE;
6965+
}
6966+
6967+
RETVAL_LONG(redis_sock->mode);
6968+
}
69506969

69516970
/*
69526971
* {{{ proto Redis::time()

0 commit comments

Comments
 (0)