diff options
author | michael-grunder <michael.grunder@gmail.com> | 2014-11-30 23:24:44 +0300 |
---|---|---|
committer | michael-grunder <michael.grunder@gmail.com> | 2015-05-06 01:12:41 +0300 |
commit | 687a5ad64a6c143dcab4b19a7a27b2834c77e9af (patch) | |
tree | 98ed0c8426b07f90d2b2b00950f38ee82796c0e5 | |
parent | 2f368bfedc18ee95b38cb3cd87e981772c05a8cf (diff) |
Implements the getMode() command
Rename command to rawCommand() as it's named in phpredis proper
This introspection function will inform the caller what mode phpredis
is in (atomic, pipeline, multi)
Conflicts:
php_redis.h
-rw-r--r-- | php_redis.h | 4 | ||||
-rw-r--r-- | redis.c | 31 | ||||
-rw-r--r-- | redis_cluster.c | 12 | ||||
-rw-r--r-- | redis_cluster.h | 2 | ||||
-rw-r--r-- | redis_commands.c | 4 | ||||
-rw-r--r-- | redis_commands.h | 2 |
6 files changed, 37 insertions, 18 deletions
diff --git a/php_redis.h b/php_redis.h index 11e7f0dd..87339f56 100644 --- a/php_redis.h +++ b/php_redis.h @@ -197,7 +197,7 @@ PHP_METHOD(Redis, wait); PHP_METHOD(Redis, pubsub); PHP_METHOD(Redis, client); -PHP_METHOD(Redis, command); +PHP_METHOD(Redis, rawcommand); /* SCAN and friends */ PHP_METHOD(Redis, scan); @@ -220,7 +220,7 @@ PHP_METHOD(Redis, isConnected); PHP_METHOD(Redis, getPersistentID); PHP_METHOD(Redis, getAuth); PHP_METHOD(Redis, getMode); -PHP_METHOD(Redis, rawCommand); +PHP_METHOD(Redis, rawcommand); #ifdef PHP_WIN32 #define PHP_REDIS_API __declspec(dllexport) @@ -266,7 +266,7 @@ static zend_function_entry redis_functions[] = { PHP_ME(Redis, _unserialize, NULL, ZEND_ACC_PUBLIC) PHP_ME(Redis, client, NULL, ZEND_ACC_PUBLIC) - PHP_ME(Redis, command, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Redis, rawcommand, NULL, ZEND_ACC_PUBLIC) /* SCAN and friends */ PHP_ME(Redis, scan, arginfo_scan, ZEND_ACC_PUBLIC) @@ -3482,6 +3482,25 @@ PHP_METHOD(Redis, clearLastError) { RETVAL_LONG(redis_sock->mode); } +/* + * {{{ proto long Redis::getMode() + */ +PHP_METHOD(Redis, getMode) { + zval *object; + RedisSock *redis_sock; + + /* Grab our object */ + if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &object, redis_ce) == FAILURE) { + RETURN_FALSE; + } + + /* Grab socket */ + if (redis_sock_get(object, &redis_sock TSRMLS_CC, 0) < 0) { + RETURN_FALSE; + } + + RETVAL_LONG(redis_sock->mode); +} /* {{{ proto Redis::time() */ PHP_METHOD(Redis, time) { @@ -3648,11 +3667,11 @@ PHP_METHOD(Redis, client) { } } -/* proto array Redis::command() - * proto array Redis::command('info', string cmd) - * proto array Redis::command('getkeys', array cmd_args) */ -PHP_METHOD(Redis, command) { - REDIS_PROCESS_CMD(command, redis_read_variant_reply); +/* proto array Redis::rawcommand() + * proto array Redis::rawcommand('info', string cmd) + * proto array Redis::rawcommand('getkeys', array cmd_args) */ +PHP_METHOD(Redis, rawcommand) { + REDIS_PROCESS_CMD(rawcommand, redis_read_variant_reply); } /* }}} */ diff --git a/redis_cluster.c b/redis_cluster.c index a4ebeb5e..d083f7ff 100644 --- a/redis_cluster.c +++ b/redis_cluster.c @@ -208,7 +208,7 @@ zend_function_entry redis_cluster_functions[] = { PHP_ME(RedisCluster, randomkey, NULL, ZEND_ACC_PUBLIC) PHP_ME(RedisCluster, ping, NULL, ZEND_ACC_PUBLIC) PHP_ME(RedisCluster, echo, NULL, ZEND_ACC_PUBLIC) - PHP_ME(RedisCluster, command, NULL, ZEND_ACC_PUBLIC) + PHP_ME(RedisCluster, rawcommand, NULL, ZEND_ACC_PUBLIC) PHP_ME(RedisCluster, cluster, NULL, ZEND_ACC_PUBLIC) PHP_ME(RedisCluster, client, NULL, ZEND_ACC_PUBLIC) PHP_ME(RedisCluster, config, NULL, ZEND_ACC_PUBLIC) @@ -2714,11 +2714,11 @@ PHP_METHOD(RedisCluster, echo) { } /* }}} */ -/* {{{ proto array RedisCluster::command() - * proto array RedisCluster::command('INFO', string cmd) - * proto array RedisCluster::command('GETKEYS', array cmd_args) */ -PHP_METHOD(RedisCluster, command) { - CLUSTER_PROCESS_CMD(command, cluster_variant_resp, 0); +/* {{{ proto array RedisCluster::rawcommand() + * proto array RedisCluster::rawcommand('INFO', string cmd) + * proto array RedisCluster::rawcommand('GETKEYS', array cmd_args) */ +PHP_METHOD(RedisCluster, rawcommand) { + CLUSTER_PROCESS_CMD(rawcommand, cluster_variant_resp, 0); } /* }}} */ diff --git a/redis_cluster.h b/redis_cluster.h index a801fc51..c2749449 100644 --- a/redis_cluster.h +++ b/redis_cluster.h @@ -264,7 +264,7 @@ PHP_METHOD(RedisCluster, time); PHP_METHOD(RedisCluster, randomkey); PHP_METHOD(RedisCluster, ping); PHP_METHOD(RedisCluster, echo); -PHP_METHOD(RedisCluster, command); +PHP_METHOD(RedisCluster, rawcommand); /* Introspection */ PHP_METHOD(RedisCluster, getlasterror); diff --git a/redis_commands.c b/redis_commands.c index 3ccd64fb..a535de5d 100644 --- a/redis_commands.c +++ b/redis_commands.c @@ -2578,8 +2578,8 @@ int redis_sdiffstore_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, } /* COMMAND */ -int redis_command_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, - char **cmd, int *cmd_len, short *slot, void **ctx) +int redis_rawcommand_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, + char **cmd, int *cmd_len, short *slot, void **ctx) { char *kw=NULL; zval *z_arg; diff --git a/redis_commands.h b/redis_commands.h index f54ea019..c2f72bf9 100644 --- a/redis_commands.h +++ b/redis_commands.h @@ -209,7 +209,7 @@ int redis_sdiff_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, int redis_sdiffstore_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, char **cmd, int *cmd_len, short *slot, void **ctx); -int redis_command_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, +int redis_rawcommand_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, char **cmd, int *cmd_len, short *slot, void **ctx); int redis_fmt_scan_cmd(char **cmd, REDIS_SCAN_TYPE type, char *key, int key_len, |