Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/phpredis/phpredis.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--redis.c538
-rw-r--r--redis_array.c4
2 files changed, 271 insertions, 271 deletions
diff --git a/redis.c b/redis.c
index b565069d..1158e2a2 100644
--- a/redis.c
+++ b/redis.c
@@ -413,7 +413,7 @@ PHP_REDIS_API int redis_sock_get(zval *id, RedisSock **redis_sock TSRMLS_DC, int
if (Z_TYPE_P(id) != IS_OBJECT || zend_hash_find(Z_OBJPROP_P(id), "socket",
sizeof("socket"), (void **) &socket) == FAILURE) {
- // Throw an exception unless we've been requested not to
+ /* Throw an exception unless we've been requested not to */
if(!no_throw) {
zend_throw_exception(redis_exception_ce, "Redis server went away", 0 TSRMLS_CC);
}
@@ -423,7 +423,7 @@ PHP_REDIS_API int redis_sock_get(zval *id, RedisSock **redis_sock TSRMLS_DC, int
*redis_sock = (RedisSock *) zend_list_find(Z_LVAL_PP(socket), &resource_type);
if (!*redis_sock || resource_type != le_redis_sock) {
- // Throw an exception unless we've been requested not to
+ /* Throw an exception unless we've been requested not to */
if(!no_throw) {
zend_throw_exception(redis_exception_ce, "Redis server went away", 0 TSRMLS_CC);
}
@@ -448,14 +448,14 @@ PHP_REDIS_API RedisSock *redis_sock_get_connected(INTERNAL_FUNCTION_PARAMETERS)
zval *object;
RedisSock *redis_sock;
- // If we can't grab our object, or get a socket, or we're not connected, return NULL
+ /* If we can't grab our object, or get a socket, or we're not connected, return NULL */
if((zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &object, redis_ce) == FAILURE) ||
(redis_sock_get(object, &redis_sock TSRMLS_CC, 1) < 0) || redis_sock->status != REDIS_SOCK_STATUS_CONNECTED)
{
return NULL;
}
- // Return our socket
+ /* Return our socket */
return redis_sock;
}
@@ -593,14 +593,14 @@ PHP_METHOD(Redis,__destruct) {
RETURN_FALSE;
}
- // Grab our socket
+ /* Grab our socket */
if (redis_sock_get(getThis(), &redis_sock TSRMLS_CC, 1) < 0) {
RETURN_FALSE;
}
- // If we think we're in MULTI mode, send a discard
+ /* If we think we're in MULTI mode, send a discard */
if(redis_sock->mode == MULTI) {
- // Discard any multi commands, and free any callbacks that have been queued
+ /* Discard any multi commands, and free any callbacks that have been queued */
send_discard_static(redis_sock TSRMLS_CC);
free_reply_callbacks(getThis(), redis_sock);
}
@@ -847,15 +847,15 @@ PHP_METHOD(Redis, bitpos)
RETURN_FALSE;
}
- // We can prevalidate the first argument
+ /* We can prevalidate the first argument */
if(bit != 0 && bit != 1) {
RETURN_FALSE;
}
- // Prefix our key
+ /* Prefix our key */
key_free = redis_key_prefix(redis_sock, &key, &key_len TSRMLS_CC);
- // Various command semantics
+ /* Various command semantics */
if(argc == 2) {
cmd_len = redis_cmd_format_static(&cmd, "BITPOS", "sd", key, key_len,
bit);
@@ -867,7 +867,7 @@ PHP_METHOD(Redis, bitpos)
bit, start, end);
}
- // Free our key if it was prefixed
+ /* Free our key if it was prefixed */
if(key_free) efree(key);
REDIS_PROCESS_REQUEST(redis_sock, cmd, cmd_len);
@@ -912,7 +912,7 @@ PHP_METHOD(Redis, set) {
int val_free = 0, key_free = 0;
zval *z_value, *z_opts = NULL;
- // Make sure the arguments are correct
+ /* Make sure the arguments are correct */
if(zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Osz|z",
&object, redis_ce, &key, &key_len, &z_value,
&z_opts) == FAILURE)
@@ -920,7 +920,7 @@ PHP_METHOD(Redis, set) {
RETURN_FALSE;
}
- // Ensure we can grab our redis socket
+ /* Ensure we can grab our redis socket */
if(redis_sock_get(object, &redis_sock TSRMLS_CC, 0) < 0) {
RETURN_FALSE;
}
@@ -950,7 +950,7 @@ PHP_METHOD(Redis, set) {
zend_hash_has_more_elements(kt) == SUCCESS;
zend_hash_move_forward(kt))
{
- // Grab key and value
+ /* Grab key and value */
type = zend_hash_get_current_key_ex(kt, &k, &ht_key_len, &idx, 0, NULL);
zend_hash_get_current_data(kt, (void**)&v);
@@ -1421,7 +1421,7 @@ PHP_METHOD(Redis, incrByFloat) {
RETURN_FALSE;
}
- // Prefix key, format command, free old key if necissary
+ /* Prefix key, format command, free old key if necissary */
key_free = redis_key_prefix(redis_sock, &key, &key_len TSRMLS_CC);
cmd_len = redis_cmd_format_static(&cmd, "INCRBYFLOAT", "sf", key, key_len, val);
if(key_free) efree(key);
@@ -1490,29 +1490,29 @@ PHP_METHOD(Redis, getMultiple)
smart_str cmd = {0};
int arg_count;
- // Make sure we have proper arguments
+ /* Make sure we have proper arguments */
if(zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Oa",
&object, redis_ce, &z_args) == FAILURE) {
RETURN_FALSE;
}
- // We'll need the socket
+ /* We'll need the socket */
if(redis_sock_get(object, &redis_sock TSRMLS_CC, 0) < 0) {
RETURN_FALSE;
}
- // Grab our array
+ /* Grab our array */
hash = Z_ARRVAL_P(z_args);
- // We don't need to do anything if there aren't any keys
+ /* We don't need to do anything if there aren't any keys */
if((arg_count = zend_hash_num_elements(hash)) == 0) {
RETURN_FALSE;
}
- // Build our command header
+ /* Build our command header */
redis_cmd_init_sstr(&cmd, arg_count, "MGET", 4);
- // Iterate through and grab our keys
+ /* Iterate through and grab our keys */
for(zend_hash_internal_pointer_reset_ex(hash, &ptr);
zend_hash_get_current_data_ex(hash, (void**)&z_ele, &ptr) == SUCCESS;
zend_hash_move_forward_ex(hash, &ptr))
@@ -1521,7 +1521,7 @@ PHP_METHOD(Redis, getMultiple)
int key_len, key_free;
zval *z_tmp = NULL;
- // If the key isn't a string, turn it into one
+ /* If the key isn't a string, turn it into one */
if(Z_TYPE_PP(z_ele) == IS_STRING) {
key = Z_STRVAL_PP(z_ele);
key_len = Z_STRLEN_PP(z_ele);
@@ -1535,16 +1535,16 @@ PHP_METHOD(Redis, getMultiple)
key_len = Z_STRLEN_P(z_tmp);
}
- // Apply key prefix if necissary
+ /* Apply key prefix if necissary */
key_free = redis_key_prefix(redis_sock, &key, &key_len TSRMLS_CC);
- // Append this key to our command
+ /* Append this key to our command */
redis_cmd_append_sstr(&cmd, key, key_len);
- // Free our key if it was prefixed
+ /* Free our key if it was prefixed */
if(key_free) efree(key);
- // Free oour temporary ZVAL if we converted from a non-string
+ /* Free oour temporary ZVAL if we converted from a non-string */
if(z_tmp) {
zval_dtor(z_tmp);
efree(z_tmp);
@@ -1552,7 +1552,7 @@ PHP_METHOD(Redis, getMultiple)
}
}
- // Kick off our command
+ /* Kick off our command */
REDIS_PROCESS_REQUEST(redis_sock, cmd.c, cmd.len);
IF_ATOMIC() {
if(redis_sock_read_multibulk_reply(INTERNAL_FUNCTION_PARAM_PASSTHRU,
@@ -1830,7 +1830,7 @@ PHP_METHOD(Redis, getBit)
RETURN_FALSE;
}
- // GETBIT and SETBIT only work for 0 - 2^32-1
+ /* GETBIT and SETBIT only work for 0 - 2^32-1 */
if(offset < BITOP_MIN_OFFSET || offset > BITOP_MAX_OFFSET) {
RETURN_FALSE;
}
@@ -1864,7 +1864,7 @@ PHP_METHOD(Redis, setBit)
RETURN_FALSE;
}
- // GETBIT and SETBIT only work for 0 - 2^32-1
+ /* GETBIT and SETBIT only work for 0 - 2^32-1 */
if(offset < BITOP_MIN_OFFSET || offset > BITOP_MAX_OFFSET) {
RETURN_FALSE;
}
@@ -2417,37 +2417,37 @@ PHP_METHOD(Redis, sRandMember)
int key_len, cmd_len, key_free = 0;
long count;
- // Parse our params
+ /* Parse our params */
if(zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os|l",
&object, redis_ce, &key, &key_len, &count) == FAILURE) {
RETURN_FALSE;
}
- // Get our redis socket
+ /* Get our redis socket */
if(redis_sock_get(object, &redis_sock TSRMLS_CC, 0) < 0) {
RETURN_FALSE;
}
- // Prefix our key if necissary
+ /* Prefix our key if necissary */
key_free = redis_key_prefix(redis_sock, &key, &key_len TSRMLS_CC);
- // If we have two arguments, we're running with an optional COUNT, which will return
- // a multibulk reply. Without the argument we'll return a string response
+ /* If we have two arguments, we're running with an optional COUNT, which will return */
+ /* a multibulk reply. Without the argument we'll return a string response */
if(ZEND_NUM_ARGS() == 2) {
- // Construct our command with count
+ /* Construct our command with count */
cmd_len = redis_cmd_format_static(&cmd, "SRANDMEMBER", "sl", key, key_len, count);
} else {
- // Construct our command
+ /* Construct our command */
cmd_len = redis_cmd_format_static(&cmd, "SRANDMEMBER", "s", key, key_len);
}
- // Free our key if we prefixed it
+ /* Free our key if we prefixed it */
if(key_free) efree(key);
- // Process our command
+ /* Process our command */
REDIS_PROCESS_REQUEST(redis_sock, cmd, cmd_len);
- // Either bulk or multi-bulk depending on argument count
+ /* Either bulk or multi-bulk depending on argument count */
if(ZEND_NUM_ARGS() == 2) {
IF_ATOMIC() {
if(redis_sock_read_multibulk_reply(INTERNAL_FUNCTION_PARAM_PASSTHRU,
@@ -2655,7 +2655,7 @@ PHP_REDIS_API int generic_multiple_args_cmd(INTERNAL_FUNCTION_PARAMETERS, char *
}
if(has_timeout) {
keys_len[j] = spprintf(&keys[j], 0, "%d", timeout);
- cmd_len += 1 + integer_length(keys_len[j]) + 2 + keys_len[j] + 2; // $ + size + NL + string + NL
+ cmd_len += 1 + integer_length(keys_len[j]) + 2 + keys_len[j] + 2; /* $ + size + NL + string + NL */
j++;
real_argc++;
}
@@ -2685,7 +2685,7 @@ PHP_REDIS_API int generic_multiple_args_cmd(INTERNAL_FUNCTION_PARAMETERS, char *
keys[j] = Z_STRVAL_P(z_args[i]);
keys_len[j] = Z_STRLEN_P(z_args[i]);
- // If we have a timeout it should be the last argument, which we do not want to prefix
+ /* If we have a timeout it should be the last argument, which we do not want to prefix */
if(!has_timeout || i < argc-1) {
keys_to_free[j] = redis_key_prefix(redis_sock, &keys[j], &keys_len[j] TSRMLS_CC); /* add optional prefix TSRMLS_CC*/
}
@@ -2697,7 +2697,7 @@ PHP_REDIS_API int generic_multiple_args_cmd(INTERNAL_FUNCTION_PARAMETERS, char *
}
}
- cmd_len += 1 + integer_length(real_argc+1) + 2; // *count NL
+ cmd_len += 1 + integer_length(real_argc+1) + 2; /* *count NL */
cmd = emalloc(cmd_len+1);
sprintf(cmd, "*%d" _NL "$%d" _NL "%s" _NL, 1+real_argc, keyword_len, keyword);
@@ -2708,7 +2708,7 @@ PHP_REDIS_API int generic_multiple_args_cmd(INTERNAL_FUNCTION_PARAMETERS, char *
/* copy each key to its destination */
for(i = 0; i < real_argc; ++i) {
- sprintf(cmd + pos, "$%d" _NL, keys_len[i]); // size
+ sprintf(cmd + pos, "$%d" _NL, keys_len[i]); /* size */
pos += 1 + integer_length(keys_len[i]) + 2;
memcpy(cmd + pos, keys[i], keys_len[i]);
pos += keys_len[i];
@@ -2953,7 +2953,7 @@ PHP_METHOD(Redis, sort) {
, Z_STRLEN_PP(z_cur), Z_STRVAL_PP(z_cur), Z_STRLEN_PP(z_cur));
elements += 2;
efree(old_cmd);
- } else if(Z_TYPE_PP(z_cur) == IS_ARRAY) { // loop over the strings in that array and add them as patterns
+ } else if(Z_TYPE_PP(z_cur) == IS_ARRAY) { /* loop over the strings in that array and add them as patterns */
HashTable *keytable = Z_ARRVAL_PP(z_cur);
for(zend_hash_internal_pointer_reset(keytable);
@@ -3005,7 +3005,7 @@ PHP_METHOD(Redis, sort) {
if(zend_hash_num_elements(Z_ARRVAL_PP(z_cur)) == 2) {
zval **z_offset_pp, **z_count_pp;
- // get the two values from the table, check that they are indeed of LONG type
+ /* get the two values from the table, check that they are indeed of LONG type */
if(SUCCESS == zend_hash_index_find(Z_ARRVAL_PP(z_cur), 0, (void**)&z_offset_pp) &&
SUCCESS == zend_hash_index_find(Z_ARRVAL_PP(z_cur), 1, (void**)&z_count_pp)) {
@@ -3105,7 +3105,7 @@ PHP_REDIS_API void generic_sort_cmd(INTERNAL_FUNCTION_PARAMETERS, char *sort, in
cmd_lines[2] = estrdup("SORT");
cmd_sizes[2] = 4;
- // Prefix our key if we need to
+ /* Prefix our key if we need to */
key_free = redis_key_prefix(redis_sock, &key, &key_len TSRMLS_CC);
/* second line, key */
@@ -3115,7 +3115,7 @@ PHP_REDIS_API void generic_sort_cmd(INTERNAL_FUNCTION_PARAMETERS, char *sort, in
cmd_lines[4][key_len] = 0;
cmd_sizes[4] = key_len;
- // If we prefixed our key, free it
+ /* If we prefixed our key, free it */
if(key_free) efree(key);
cmd_elements = 5;
@@ -3505,7 +3505,7 @@ PHP_METHOD(Redis, auth) {
cmd_len = redis_cmd_format_static(&cmd, "AUTH", "s", password, password_len);
- // Free previously stored auth if we have one, and store this password
+ /* Free previously stored auth if we have one, and store this password */
if(redis_sock->auth) efree(redis_sock->auth);
redis_sock->auth = estrndup(password, password_len);
@@ -3607,7 +3607,7 @@ PHP_METHOD(Redis, info) {
RETURN_FALSE;
}
- // Build a standalone INFO command or one with an option
+ /* Build a standalone INFO command or one with an option */
if(opt != NULL) {
cmd_len = redis_cmd_format_static(&cmd, "INFO", "s", opt, opt_len);
} else {
@@ -3706,7 +3706,7 @@ generic_mset(INTERNAL_FUNCTION_PARAMETERS, char *kw, void (*fun)(INTERNAL_FUNCTI
char *cmd = NULL, *p = NULL;
int cmd_len = 0, argc = 0, kw_len = strlen(kw);
- int step = 0; // 0: compute size; 1: copy strings.
+ int step = 0; /* 0: compute size; 1: copy strings. */
zval *z_array;
HashTable *keytable;
@@ -3753,14 +3753,14 @@ generic_mset(INTERNAL_FUNCTION_PARAMETERS, char *kw, void (*fun)(INTERNAL_FUNCTI
continue; /* this should never happen, according to the PHP people. */
}
- // If the key isn't a string, use the index value returned when grabbing the
- // key. We typecast to long, because they could actually be negative.
+ /* If the key isn't a string, use the index value returned when grabbing the */
+ /* key. We typecast to long, because they could actually be negative. */
if(type != HASH_KEY_IS_STRING) {
- // Create string representation of our index
+ /* Create string representation of our index */
key_len = snprintf(buf, sizeof(buf), "%ld", (long)idx);
key = (char*)buf;
} else if(key_len > 0) {
- // When not an integer key, the length will include the \0
+ /* When not an integer key, the length will include the \0 */
key_len--;
}
@@ -3916,7 +3916,7 @@ PHP_METHOD(Redis, zAdd) {
/* need key, score, value, [score, value...] */
if(argc > 1) {
- convert_to_string(z_args[0]); // required string
+ convert_to_string(z_args[0]); /* required string */
}
if(argc < 3 || Z_TYPE_P(z_args[0]) != IS_STRING || (argc-1) % 2 != 0) {
efree(z_args);
@@ -3948,8 +3948,8 @@ PHP_METHOD(Redis, zAdd) {
smart_str_appendl(&buf, _NL, sizeof(_NL) - 1);
for(i = 1; i < argc; i +=2) {
- convert_to_double(z_args[i]); // convert score to double
- val_free = redis_serialize(redis_sock, z_args[i+1], &val, &val_len TSRMLS_CC); // possibly serialize value.
+ convert_to_double(z_args[i]); /* convert score to double */
+ val_free = redis_serialize(redis_sock, z_args[i+1], &val, &val_len TSRMLS_CC); /* possibly serialize value. */
/* add score */
score = Z_DVAL_P(z_args[i]);
@@ -4203,7 +4203,7 @@ redis_generic_zrange_by_score(INTERNAL_FUNCTION_PARAMETERS, char *keyword) {
if(zend_hash_find(Z_ARRVAL_P(z_options), "limit", sizeof("limit"), (void**)&z_limit_val_pp)== SUCCESS) {;
if(zend_hash_num_elements(Z_ARRVAL_PP(z_limit_val_pp)) == 2) {
zval **z_offset_pp, **z_count_pp;
- // get the two values from the table, check that they are indeed of LONG type
+ /* get the two values from the table, check that they are indeed of LONG type */
if(SUCCESS == zend_hash_index_find(Z_ARRVAL_PP(z_limit_val_pp), 0, (void**)&z_offset_pp) &&
SUCCESS == zend_hash_index_find(Z_ARRVAL_PP(z_limit_val_pp), 1, (void**)&z_count_pp) &&
Z_TYPE_PP(z_offset_pp) == IS_LONG &&
@@ -4476,7 +4476,7 @@ PHP_REDIS_API void generic_z_command(INTERNAL_FUNCTION_PARAMETERS, char *command
char *store_key, *agg_op = NULL;
int cmd_arg_count = 2, store_key_len, agg_op_len = 0, keys_count, key_free;
- // Grab our parameters
+ /* Grab our parameters */
if(zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Osa|a!s",
&object, redis_ce, &store_key, &store_key_len,
&z_keys, &z_weights, &agg_op, &agg_op_len) == FAILURE)
@@ -4484,40 +4484,40 @@ PHP_REDIS_API void generic_z_command(INTERNAL_FUNCTION_PARAMETERS, char *command
RETURN_FALSE;
}
- // We'll need our socket
+ /* We'll need our socket */
if(redis_sock_get(object, &redis_sock TSRMLS_CC, 0) < 0) {
RETURN_FALSE;
}
- // Grab our keys argument as an array
+ /* Grab our keys argument as an array */
ht_keys = Z_ARRVAL_P(z_keys);
- // Nothing to do if there aren't any keys
+ /* Nothing to do if there aren't any keys */
if((keys_count = zend_hash_num_elements(ht_keys)) == 0) {
RETURN_FALSE;
} else {
- // Increment our overall argument count
+ /* Increment our overall argument count */
cmd_arg_count += keys_count;
}
- // Grab and validate our weights array
+ /* Grab and validate our weights array */
if(z_weights != NULL) {
ht_weights = Z_ARRVAL_P(z_weights);
- // This command is invalid if the weights array isn't the same size
- // as our keys array.
+ /* This command is invalid if the weights array isn't the same size */
+ /* as our keys array. */
if(zend_hash_num_elements(ht_weights) != keys_count) {
RETURN_FALSE;
}
- // Increment our overall argument count by the number of keys
- // plus one, for the "WEIGHTS" argument itself
+ /* Increment our overall argument count by the number of keys */
+ /* plus one, for the "WEIGHTS" argument itself */
cmd_arg_count += keys_count + 1;
}
- // AGGREGATE option
+ /* AGGREGATE option */
if(agg_op_len != 0) {
- // Verify our aggregation option
+ /* Verify our aggregation option */
if(strncasecmp(agg_op, "SUM", sizeof("SUM")) &&
strncasecmp(agg_op, "MIN", sizeof("MIN")) &&
strncasecmp(agg_op, "MAX", sizeof("MAX")))
@@ -4525,22 +4525,22 @@ PHP_REDIS_API void generic_z_command(INTERNAL_FUNCTION_PARAMETERS, char *command
RETURN_FALSE;
}
- // Two more arguments: "AGGREGATE" and agg_op
+ /* Two more arguments: "AGGREGATE" and agg_op */
cmd_arg_count += 2;
}
- // Command header
+ /* Command header */
redis_cmd_init_sstr(&cmd, cmd_arg_count, command, command_len);
- // Prefix our key if necessary and add the output key
+ /* Prefix our key if necessary and add the output key */
key_free = redis_key_prefix(redis_sock, &store_key, &store_key_len TSRMLS_CC);
redis_cmd_append_sstr(&cmd, store_key, store_key_len);
if(key_free) efree(store_key);
- // Number of input keys argument
+ /* Number of input keys argument */
redis_cmd_append_sstr_int(&cmd, keys_count);
- // Process input keys
+ /* Process input keys */
for(zend_hash_internal_pointer_reset_ex(ht_keys, &ptr);
zend_hash_get_current_data_ex(ht_keys, (void**)&z_data, &ptr)==SUCCESS;
zend_hash_move_forward_ex(ht_keys, &ptr))
@@ -4561,16 +4561,16 @@ PHP_REDIS_API void generic_z_command(INTERNAL_FUNCTION_PARAMETERS, char *command
key_len = Z_STRLEN_P(z_tmp);
}
- // Apply key prefix if necessary
+ /* Apply key prefix if necessary */
key_free = redis_key_prefix(redis_sock, &key, &key_len TSRMLS_CC);
- // Append this input set
+ /* Append this input set */
redis_cmd_append_sstr(&cmd, key, key_len);
- // Free our key if it was prefixed
+ /* Free our key if it was prefixed */
if(key_free) efree(key);
- // Free our temporary z_val if it was converted
+ /* Free our temporary z_val if it was converted */
if(z_tmp) {
zval_dtor(z_tmp);
efree(z_tmp);
@@ -4578,29 +4578,29 @@ PHP_REDIS_API void generic_z_command(INTERNAL_FUNCTION_PARAMETERS, char *command
}
}
- // Weights
+ /* Weights */
if(ht_weights != NULL) {
- // Append "WEIGHTS" argument
+ /* Append "WEIGHTS" argument */
redis_cmd_append_sstr(&cmd, "WEIGHTS", sizeof("WEIGHTS") - 1);
- // Process weights
+ /* Process weights */
for(zend_hash_internal_pointer_reset_ex(ht_weights, &ptr);
zend_hash_get_current_data_ex(ht_weights, (void**)&z_data, &ptr)==SUCCESS;
zend_hash_move_forward_ex(ht_weights, &ptr))
{
- // Ignore non numeric arguments, unless they're special Redis numbers
+ /* Ignore non numeric arguments, unless they're special Redis numbers */
if (Z_TYPE_PP(z_data) != IS_LONG && Z_TYPE_PP(z_data) != IS_DOUBLE &&
strncasecmp(Z_STRVAL_PP(z_data), "inf", sizeof("inf")) != 0 &&
strncasecmp(Z_STRVAL_PP(z_data), "-inf", sizeof("-inf")) != 0 &&
strncasecmp(Z_STRVAL_PP(z_data), "+inf", sizeof("+inf")) != 0)
{
- // We should abort if we have an invalid weight, rather than pass
- // a different number of weights than the user is expecting
+ /* We should abort if we have an invalid weight, rather than pass */
+ /* a different number of weights than the user is expecting */
efree(cmd.c);
RETURN_FALSE;
}
- // Append the weight based on the input type
+ /* Append the weight based on the input type */
switch(Z_TYPE_PP(z_data)) {
case IS_LONG:
redis_cmd_append_sstr_long(&cmd, Z_LVAL_PP(z_data));
@@ -4615,13 +4615,13 @@ PHP_REDIS_API void generic_z_command(INTERNAL_FUNCTION_PARAMETERS, char *command
}
}
- // Aggregation options, if we have them
+ /* Aggregation options, if we have them */
if(agg_op_len != 0) {
redis_cmd_append_sstr(&cmd, "AGGREGATE", sizeof("AGGREGATE") - 1);
redis_cmd_append_sstr(&cmd, agg_op, agg_op_len);
}
- // Kick off our request
+ /* Kick off our request */
REDIS_PROCESS_REQUEST(redis_sock, cmd.c, cmd.len);
IF_ATOMIC() {
redis_long_response(INTERNAL_FUNCTION_PARAM_PASSTHRU, redis_sock, NULL, NULL);
@@ -4964,14 +4964,14 @@ PHP_METHOD(Redis, hIncrByFloat)
int key_len, member_len, cmd_len, key_free;
double val;
- // Validate we have the right number of arguments
+ /* Validate we have the right number of arguments */
if(zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Ossd",
&object, redis_ce,
&key, &key_len, &member, &member_len, &val) == FAILURE) {
RETURN_FALSE;
}
- // Grab our socket
+ /* Grab our socket */
if(redis_sock_get(object, &redis_sock TSRMLS_CC, 0) < 0) {
RETURN_FALSE;
}
@@ -5040,7 +5040,7 @@ PHP_METHOD(Redis, hMget) {
HashPosition ptr;
smart_str cmd = {0};
- // Make sure we can grab our arguments properly
+ /* Make sure we can grab our arguments properly */
if(zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Osa",
&object, redis_ce, &key, &key_len, &z_array)
== FAILURE)
@@ -5048,68 +5048,68 @@ PHP_METHOD(Redis, hMget) {
RETURN_FALSE;
}
- // We'll need our socket
+ /* We'll need our socket */
if(redis_sock_get(object, &redis_sock TSRMLS_CC, 0) < 0) {
RETURN_FALSE;
}
- // Grab member count and abort if we don't have any
+ /* Grab member count and abort if we don't have any */
if((field_count = zend_hash_num_elements(Z_ARRVAL_P(z_array))) == 0) {
RETURN_FALSE;
}
- // Prefix our key if we need to
+ /* Prefix our key if we need to */
key_free = redis_key_prefix(redis_sock, &key, &key_len TSRMLS_CC);
- // Allocate enough memory for the number of keys being requested
+ /* Allocate enough memory for the number of keys being requested */
z_keys = ecalloc(field_count, sizeof(zval *));
- // Grab our HashTable
+ /* Grab our HashTable */
ht_array = Z_ARRVAL_P(z_array);
- // Iterate through our keys, grabbing members that are valid
+ /* Iterate through our keys, grabbing members that are valid */
for(valid=0, zend_hash_internal_pointer_reset_ex(ht_array, &ptr);
zend_hash_get_current_data_ex(ht_array, (void**)&data, &ptr)==SUCCESS;
zend_hash_move_forward_ex(ht_array, &ptr))
{
- // Make sure the data is a long or string, and if it's a string that
- // it isn't empty. There is no reason to send empty length members.
+ /* Make sure the data is a long or string, and if it's a string that */
+ /* it isn't empty. There is no reason to send empty length members. */
if((Z_TYPE_PP(data) == IS_STRING && Z_STRLEN_PP(data)>0) ||
Z_TYPE_PP(data) == IS_LONG)
{
- // This is a key we can ask for, copy it and set it in our array
+ /* This is a key we can ask for, copy it and set it in our array */
MAKE_STD_ZVAL(z_keys[valid]);
*z_keys[valid] = **data;
zval_copy_ctor(z_keys[valid]);
convert_to_string(z_keys[valid]);
- // Increment the number of valid keys we've encountered
+ /* Increment the number of valid keys we've encountered */
valid++;
}
}
- // If we don't have any valid keys, we can abort here
+ /* If we don't have any valid keys, we can abort here */
if(valid == 0) {
if(key_free) efree(key);
efree(z_keys);
RETURN_FALSE;
}
- // Build command header. One extra argument for the hash key itself
+ /* Build command header. One extra argument for the hash key itself */
redis_cmd_init_sstr(&cmd, valid+1, "HMGET", sizeof("HMGET")-1);
- // Add the hash key
+ /* Add the hash key */
redis_cmd_append_sstr(&cmd, key, key_len);
- // Free key memory if it was prefixed
+ /* Free key memory if it was prefixed */
if(key_free) efree(key);
- // Iterate our keys, appending them as arguments
+ /* Iterate our keys, appending them as arguments */
for(i=0;i<valid;i++) {
redis_cmd_append_sstr(&cmd, Z_STRVAL_P(z_keys[i]), Z_STRLEN_P(z_keys[i]));
}
- // Kick off our request
+ /* Kick off our request */
REDIS_PROCESS_REQUEST(redis_sock, cmd.c, cmd.len);
IF_ATOMIC() {
redis_sock_read_multibulk_reply_assoc(INTERNAL_FUNCTION_PARAM_PASSTHRU, redis_sock, NULL, z_keys);
@@ -5179,19 +5179,19 @@ PHP_METHOD(Redis, hMset)
/* key is set. */
hval_free = redis_serialize(redis_sock, *z_value_p, &hval, &hval_len TSRMLS_CC);
- // Append our member and value in place
+ /* Append our member and value in place */
redis_cmd_append_sstr(&set_cmds, hkey, hkey_len - 1);
redis_cmd_append_sstr(&set_cmds, hval, hval_len);
if(hval_free) STR_FREE(hval);
}
- // Now construct the entire command
+ /* Now construct the entire command */
old_cmd = cmd;
cmd_len = redis_cmd_format(&cmd, "*%d" _NL "%s%s", element_count, cmd, cmd_len, set_cmds.c, set_cmds.len);
efree(old_cmd);
- // Free the HMSET bits
+ /* Free the HMSET bits */
efree(set_cmds.c);
REDIS_PROCESS_REQUEST(redis_sock, cmd, cmd_len);
@@ -5546,7 +5546,7 @@ PHP_REDIS_API void generic_subscribe_cmd(INTERNAL_FUNCTION_PARAMETERS, char *sub
char *type_response;
int is_pmsg, tab_idx;
- // Function call information
+ /* Function call information */
zend_fcall_info z_callback;
zend_fcall_info_cache z_callback_cache;
@@ -5578,11 +5578,11 @@ PHP_REDIS_API void generic_subscribe_cmd(INTERNAL_FUNCTION_PARAMETERS, char *sub
old_cmd = cmd;
}
- // Grab our key and len
+ /* Grab our key and len */
key = Z_STRVAL_PP(data);
key_len = Z_STRLEN_PP(data);
- // Prefix our key if neccisary
+ /* Prefix our key if neccisary */
key_free = redis_key_prefix(redis_sock, &key, &key_len TSRMLS_CC);
cmd_len = spprintf(&cmd, 0, "%s %s", cmd, key);
@@ -5591,7 +5591,7 @@ PHP_REDIS_API void generic_subscribe_cmd(INTERNAL_FUNCTION_PARAMETERS, char *sub
efree(old_cmd);
}
- // Free our key if it was prefixed
+ /* Free our key if it was prefixed */
if(key_free) {
efree(key);
}
@@ -5627,7 +5627,7 @@ PHP_REDIS_API void generic_subscribe_cmd(INTERNAL_FUNCTION_PARAMETERS, char *sub
}
efree(z_tab);
- // Set a pointer to our return value and to our arguments.
+ /* Set a pointer to our return value and to our arguments. */
z_callback.retval_ptr_ptr = &z_ret;
z_callback.params = z_args;
z_callback.no_separation = 0;
@@ -5640,7 +5640,7 @@ PHP_REDIS_API void generic_subscribe_cmd(INTERNAL_FUNCTION_PARAMETERS, char *sub
tab_idx = 1;
if(z_tab == NULL || Z_TYPE_P(z_tab) != IS_ARRAY) {
- //ERROR
+ /*ERROR */
break;
}
@@ -5648,23 +5648,23 @@ PHP_REDIS_API void generic_subscribe_cmd(INTERNAL_FUNCTION_PARAMETERS, char *sub
break;
}
- // Make sure we have a message or pmessage
+ /* Make sure we have a message or pmessage */
if(!strncmp(Z_STRVAL_PP(type), "message", 7) || !strncmp(Z_STRVAL_PP(type), "pmessage", 8)) {
- // Is this a pmessage
+ /* Is this a pmessage */
is_pmsg = *Z_STRVAL_PP(type) == 'p';
} else {
- continue; // It's not a message or pmessage
+ continue; /* It's not a message or pmessage */
}
- // If this is a pmessage, we'll want to extract the pattern first
+ /* If this is a pmessage, we'll want to extract the pattern first */
if(is_pmsg) {
- // Extract pattern
+ /* Extract pattern */
if(zend_hash_index_find(Z_ARRVAL_P(z_tab), tab_idx++, (void**)&pattern) == FAILURE) {
break;
}
}
- // Extract channel and data
+ /* Extract channel and data */
if (zend_hash_index_find(Z_ARRVAL_P(z_tab), tab_idx++, (void**)&channel) == FAILURE) {
break;
}
@@ -5672,10 +5672,10 @@ PHP_REDIS_API void generic_subscribe_cmd(INTERNAL_FUNCTION_PARAMETERS, char *sub
break;
}
- // Always pass the Redis object through
+ /* Always pass the Redis object through */
z_args[0] = &getThis();
- // Set up our callback args depending on the message type
+ /* Set up our callback args depending on the message type */
if(is_pmsg) {
z_args[1] = pattern;
z_args[2] = channel;
@@ -5685,15 +5685,15 @@ PHP_REDIS_API void generic_subscribe_cmd(INTERNAL_FUNCTION_PARAMETERS, char *sub
z_args[2] = data;
}
- // Set our argument information
+ /* Set our argument information */
z_callback.param_count = tab_idx;
- // Break if we can't call the function
+ /* Break if we can't call the function */
if(zend_call_function(&z_callback, &z_callback_cache TSRMLS_CC) != SUCCESS) {
break;
}
- // If we have a return value, free it. Note, we could use the return value to break the subscribe loop
+ /* If we have a return value, free it. Note, we could use the return value to break the subscribe loop */
if(z_ret) zval_ptr_dtor(&z_ret);
/* TODO: provide a way to break out of the loop. */
@@ -5793,7 +5793,7 @@ PHP_REDIS_API void generic_unsubscribe_cmd(INTERNAL_FUNCTION_PARAMETERS, char *u
}
add_assoc_bool(return_value, Z_STRVAL_PP(z_channel), 1);
} else {
- //error
+ /*error */
efree(z_tab);
RETURN_FALSE;
}
@@ -6059,14 +6059,14 @@ PHP_METHOD(Redis, slowlog) {
long option;
enum {SLOWLOG_GET, SLOWLOG_LEN, SLOWLOG_RESET} mode;
- // Make sure we can get parameters
+ /* Make sure we can get parameters */
if(zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os|l",
&object, redis_ce, &arg, &arg_len, &option) == FAILURE)
{
RETURN_FALSE;
}
- // Figure out what kind of slowlog command we're executing
+ /* Figure out what kind of slowlog command we're executing */
if(!strncasecmp(arg, "GET", 3)) {
mode = SLOWLOG_GET;
} else if(!strncasecmp(arg, "LEN", 3)) {
@@ -6074,23 +6074,23 @@ PHP_METHOD(Redis, slowlog) {
} else if(!strncasecmp(arg, "RESET", 5)) {
mode = SLOWLOG_RESET;
} else {
- // This command is not valid
+ /* This command is not valid */
RETURN_FALSE;
}
- // Make sure we can grab our redis socket
+ /* Make sure we can grab our redis socket */
if(redis_sock_get(object, &redis_sock TSRMLS_CC, 0) < 0) {
RETURN_FALSE;
}
- // Create our command. For everything except SLOWLOG GET (with an arg) it's just two parts
+ /* Create our command. For everything except SLOWLOG GET (with an arg) it's just two parts */
if(mode == SLOWLOG_GET && ZEND_NUM_ARGS() == 2) {
cmd_len = redis_cmd_format_static(&cmd, "SLOWLOG", "sl", arg, arg_len, option);
} else {
cmd_len = redis_cmd_format_static(&cmd, "SLOWLOG", "s", arg, arg_len);
}
- // Kick off our command
+ /* Kick off our command */
REDIS_PROCESS_REQUEST(redis_sock, cmd, cmd_len);
IF_ATOMIC() {
if(redis_read_variant_reply(INTERNAL_FUNCTION_PARAM_PASSTHRU, redis_sock, NULL) < 0) {
@@ -6109,7 +6109,7 @@ PHP_METHOD(Redis, wait) {
char *cmd;
int cmd_len;
- // Make sure arguments are valid
+ /* Make sure arguments are valid */
if(zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Oll",
&object, redis_ce, &num_slaves, &timeout)
==FAILURE)
@@ -6117,20 +6117,20 @@ PHP_METHOD(Redis, wait) {
RETURN_FALSE;
}
- // Don't even send this to Redis if our args are negative
+ /* Don't even send this to Redis if our args are negative */
if(num_slaves < 0 || timeout < 0) {
RETURN_FALSE;
}
- // Grab our socket
+ /* Grab our socket */
if(redis_sock_get(object, &redis_sock TSRMLS_CC, 0)<0) {
RETURN_FALSE;
}
- // Construct the command
+ /* Construct the command */
cmd_len = redis_cmd_format_static(&cmd, "WAIT", "ll", num_slaves, timeout);
- // Kick it off
+ /* Kick it off */
REDIS_PROCESS_REQUEST(redis_sock, cmd, cmd_len);
IF_ATOMIC() {
redis_long_response(INTERNAL_FUNCTION_PARAM_PASSTHRU, redis_sock, NULL, NULL);
@@ -6154,34 +6154,34 @@ redis_build_pubsub_cmd(RedisSock *redis_sock, char **ret, PUBSUB_TYPE type,
if(type == PUBSUB_CHANNELS) {
if(arg) {
- // Get string argument and length.
+ /* Get string argument and length. */
key = Z_STRVAL_P(arg);
key_len = Z_STRLEN_P(arg);
- // Prefix if necissary
+ /* Prefix if necissary */
key_free = redis_key_prefix(redis_sock, &key, &key_len TSRMLS_CC);
- // With a pattern
+ /* With a pattern */
cmd_len = redis_cmd_format_static(ret, "PUBSUB", "ss", "CHANNELS", sizeof("CHANNELS")-1,
key, key_len);
- // Free the channel name if we prefixed it
+ /* Free the channel name if we prefixed it */
if(key_free) efree(key);
- // Return command length
+ /* Return command length */
return cmd_len;
} else {
- // No pattern
+ /* No pattern */
return redis_cmd_format_static(ret, "PUBSUB", "s", "CHANNELS", sizeof("CHANNELS")-1);
}
} else if(type == PUBSUB_NUMSUB) {
ht_chan = Z_ARRVAL_P(arg);
- // Add PUBSUB and NUMSUB bits
+ /* Add PUBSUB and NUMSUB bits */
redis_cmd_init_sstr(&cmd, zend_hash_num_elements(ht_chan)+1, "PUBSUB", sizeof("PUBSUB")-1);
redis_cmd_append_sstr(&cmd, "NUMSUB", sizeof("NUMSUB")-1);
- // Iterate our elements
+ /* Iterate our elements */
for(zend_hash_internal_pointer_reset_ex(ht_chan, &ptr);
zend_hash_get_current_data_ex(ht_chan, (void**)&z_ele, &ptr)==SUCCESS;
zend_hash_move_forward_ex(ht_chan, &ptr))
@@ -6203,16 +6203,16 @@ redis_build_pubsub_cmd(RedisSock *redis_sock, char **ret, PUBSUB_TYPE type,
key_len = Z_STRLEN_P(z_tmp);
}
- // Apply prefix if required
+ /* Apply prefix if required */
key_free = redis_key_prefix(redis_sock, &key, &key_len TSRMLS_CC);
- // Append this channel
+ /* Append this channel */
redis_cmd_append_sstr(&cmd, key, key_len);
- // Free key if prefixed
+ /* Free key if prefixed */
if(key_free) efree(key);
- // Free our temp var if we converted from something other than a string
+ /* Free our temp var if we converted from something other than a string */
if(z_tmp) {
zval_dtor(z_tmp);
efree(z_tmp);
@@ -6220,14 +6220,14 @@ redis_build_pubsub_cmd(RedisSock *redis_sock, char **ret, PUBSUB_TYPE type,
}
}
- // Set return
+ /* Set return */
*ret = cmd.c;
return cmd.len;
} else if(type == PUBSUB_NUMPAT) {
return redis_cmd_format_static(ret, "PUBSUB", "s", "NUMPAT", sizeof("NUMPAT")-1);
}
- // Shouldn't ever happen
+ /* Shouldn't ever happen */
return -1;
}
@@ -6244,7 +6244,7 @@ PHP_METHOD(Redis, pubsub) {
PUBSUB_TYPE type;
zval *arg=NULL;
- // Parse arguments
+ /* Parse arguments */
if(zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os|z",
&object, redis_ce, &keyword, &kw_len, &arg)
==FAILURE)
@@ -6252,15 +6252,15 @@ PHP_METHOD(Redis, pubsub) {
RETURN_FALSE;
}
- // Validate our sub command keyword, and that we've got proper arguments
+ /* Validate our sub command keyword, and that we've got proper arguments */
if(!strncasecmp(keyword, "channels", sizeof("channels"))) {
- // One (optional) string argument
+ /* One (optional) string argument */
if(arg && Z_TYPE_P(arg) != IS_STRING) {
RETURN_FALSE;
}
type = PUBSUB_CHANNELS;
} else if(!strncasecmp(keyword, "numsub", sizeof("numsub"))) {
- // One array argument
+ /* One array argument */
if(ZEND_NUM_ARGS() < 2 || Z_TYPE_P(arg) != IS_ARRAY ||
zend_hash_num_elements(Z_ARRVAL_P(arg))==0)
{
@@ -6270,16 +6270,16 @@ PHP_METHOD(Redis, pubsub) {
} else if(!strncasecmp(keyword, "numpat", sizeof("numpat"))) {
type = PUBSUB_NUMPAT;
} else {
- // Invalid keyword
+ /* Invalid keyword */
RETURN_FALSE;
}
- // Grab our socket context object
+ /* Grab our socket context object */
if(redis_sock_get(object, &redis_sock TSRMLS_CC, 0)<0) {
RETURN_FALSE;
}
- // Construct our "PUBSUB" command
+ /* Construct our "PUBSUB" command */
cmd_len = redis_build_pubsub_cmd(redis_sock, &cmd, type, arg TSRMLS_CC);
REDIS_PROCESS_REQUEST(redis_sock, cmd, cmd_len);
@@ -6301,7 +6301,7 @@ PHP_METHOD(Redis, pubsub) {
}
}
-// Construct an EVAL or EVALSHA command, with option argument array and number of arguments that are keys parameter
+/* Construct an EVAL or EVALSHA command, with option argument array and number of arguments that are keys parameter */
PHP_REDIS_API int
redis_build_eval_cmd(RedisSock *redis_sock, char **ret, char *keyword, char *value, int val_len, zval *args, int keys_count TSRMLS_DC) {
zval **elem;
@@ -6310,22 +6310,22 @@ redis_build_eval_cmd(RedisSock *redis_sock, char **ret, char *keyword, char *val
int cmd_len, args_count = 0;
int eval_cmd_count = 2;
- // If we've been provided arguments, we'll want to include those in our eval command
+ /* If we've been provided arguments, we'll want to include those in our eval command */
if(args != NULL) {
- // Init our hash array value, and grab the count
+ /* Init our hash array value, and grab the count */
args_hash = Z_ARRVAL_P(args);
args_count = zend_hash_num_elements(args_hash);
- // We only need to process the arguments if the array is non empty
+ /* We only need to process the arguments if the array is non empty */
if(args_count > 0) {
- // Header for our EVAL command
+ /* Header for our EVAL command */
cmd_len = redis_cmd_format_header(ret, keyword, eval_cmd_count + args_count);
- // Now append the script itself, and the number of arguments to treat as keys
+ /* Now append the script itself, and the number of arguments to treat as keys */
cmd_len = redis_cmd_append_str(ret, cmd_len, value, val_len);
cmd_len = redis_cmd_append_int(ret, cmd_len, keys_count);
- // Iterate the values in our "keys" array
+ /* Iterate the values in our "keys" array */
for(zend_hash_internal_pointer_reset_ex(args_hash, &hash_pos);
zend_hash_get_current_data_ex(args_hash, (void **)&elem, &hash_pos) == SUCCESS;
zend_hash_move_forward_ex(args_hash, &hash_pos))
@@ -6338,7 +6338,7 @@ redis_build_eval_cmd(RedisSock *redis_sock, char **ret, char *keyword, char *val
key = Z_STRVAL_PP(elem);
key_len = Z_STRLEN_PP(elem);
} else {
- // Convert it to a string
+ /* Convert it to a string */
MAKE_STD_ZVAL(z_tmp);
*z_tmp = **elem;
zval_copy_ctor(z_tmp);
@@ -6348,20 +6348,20 @@ redis_build_eval_cmd(RedisSock *redis_sock, char **ret, char *keyword, char *val
key_len = Z_STRLEN_P(z_tmp);
}
- // Keep track of the old command pointer
+ /* Keep track of the old command pointer */
old_cmd = *ret;
- // If this is still a key argument, prefix it if we've been set up to prefix keys
+ /* If this is still a key argument, prefix it if we've been set up to prefix keys */
key_free = keys_count-- > 0 ? redis_key_prefix(redis_sock, &key, &key_len TSRMLS_CC) : 0;
- // Append this key to our EVAL command, free our old command
+ /* Append this key to our EVAL command, free our old command */
cmd_len = redis_cmd_format(ret, "%s$%d" _NL "%s" _NL, *ret, cmd_len, key_len, key, key_len);
efree(old_cmd);
- // Free our key, old command if we need to
+ /* Free our key, old command if we need to */
if(key_free) efree(key);
- // Free our temporary zval (converted from non string) if we've got one
+ /* Free our temporary zval (converted from non string) if we've got one */
if(z_tmp) {
zval_dtor(z_tmp);
efree(z_tmp);
@@ -6370,12 +6370,12 @@ redis_build_eval_cmd(RedisSock *redis_sock, char **ret, char *keyword, char *val
}
}
- // If there weren't any arguments (none passed, or an empty array), construct a standard no args command
+ /* If there weren't any arguments (none passed, or an empty array), construct a standard no args command */
if(args_count < 1) {
cmd_len = redis_cmd_format_static(ret, keyword, "sd", value, val_len, 0);
}
- // Return our command length
+ /* Return our command length */
return cmd_len;
}
@@ -6394,12 +6394,12 @@ PHP_METHOD(Redis, evalsha)
RETURN_FALSE;
}
- // Attempt to grab socket
+ /* Attempt to grab socket */
if(redis_sock_get(object, &redis_sock TSRMLS_CC, 0) < 0) {
RETURN_FALSE;
}
- // Construct our EVALSHA command
+ /* Construct our EVALSHA command */
cmd_len = redis_build_eval_cmd(redis_sock, &cmd, "EVALSHA", sha, sha_len, args, keys_count TSRMLS_CC);
REDIS_PROCESS_REQUEST(redis_sock, cmd, cmd_len);
@@ -6421,18 +6421,18 @@ PHP_METHOD(Redis, eval)
int script_len, cmd_len;
long keys_count = 0;
- // Attempt to parse parameters
+ /* Attempt to parse parameters */
if(zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os|al",
&object, redis_ce, &script, &script_len, &args, &keys_count) == FAILURE) {
RETURN_FALSE;
}
- // Attempt to grab socket
+ /* Attempt to grab socket */
if (redis_sock_get(object, &redis_sock TSRMLS_CC, 0) < 0) {
RETURN_FALSE;
}
- // Construct our EVAL command
+ /* Construct our EVAL command */
cmd_len = redis_build_eval_cmd(redis_sock, &cmd, "EVAL", script, script_len, args, keys_count TSRMLS_CC);
REDIS_PROCESS_REQUEST(redis_sock, cmd, cmd_len);
@@ -6446,23 +6446,23 @@ PHP_METHOD(Redis, eval)
PHP_REDIS_API int
redis_build_script_exists_cmd(char **ret, zval **argv, int argc) {
- // Our command length and iterator
+ /* Our command length and iterator */
int cmd_len = 0, i;
- // Start building our command
- cmd_len = redis_cmd_format_header(ret, "SCRIPT", argc + 1); // +1 for "EXISTS"
+ /* Start building our command */
+ cmd_len = redis_cmd_format_header(ret, "SCRIPT", argc + 1); /* +1 for "EXISTS" */
cmd_len = redis_cmd_append_str(ret, cmd_len, "EXISTS", 6);
- // Iterate our arguments
+ /* Iterate our arguments */
for(i=0;i<argc;i++) {
- // Convert our argument to a string if we need to
+ /* Convert our argument to a string if we need to */
convert_to_string(argv[i]);
- // Append this script sha to our SCRIPT EXISTS command
+ /* Append this script sha to our SCRIPT EXISTS command */
cmd_len = redis_cmd_append_str(ret, cmd_len, Z_STRVAL_P(argv[i]), Z_STRLEN_P(argv[i]));
}
- // Success
+ /* Success */
return cmd_len;
}
@@ -6477,18 +6477,18 @@ PHP_METHOD(Redis, script) {
int cmd_len, argc;
char *cmd;
- // Attempt to grab our socket
+ /* Attempt to grab our socket */
if(redis_sock_get(getThis(), &redis_sock TSRMLS_CC, 0) < 0) {
RETURN_FALSE;
}
- // Grab the number of arguments
+ /* Grab the number of arguments */
argc = ZEND_NUM_ARGS();
- // Allocate an array big enough to store our arguments
+ /* Allocate an array big enough to store our arguments */
z_args = emalloc(argc * sizeof(zval*));
- // Make sure we can grab our arguments, we have a string directive
+ /* Make sure we can grab our arguments, we have a string directive */
if(zend_get_parameters_array(ht, argc, z_args) == FAILURE ||
(argc < 1 || Z_TYPE_P(z_args[0]) != IS_STRING))
{
@@ -6496,34 +6496,34 @@ PHP_METHOD(Redis, script) {
RETURN_FALSE;
}
- // Branch based on the directive
+ /* Branch based on the directive */
if(!strcasecmp(Z_STRVAL_P(z_args[0]), "flush") || !strcasecmp(Z_STRVAL_P(z_args[0]), "kill")) {
- // Simple SCRIPT FLUSH, or SCRIPT_KILL command
+ /* Simple SCRIPT FLUSH, or SCRIPT_KILL command */
cmd_len = redis_cmd_format_static(&cmd, "SCRIPT", "s", Z_STRVAL_P(z_args[0]), Z_STRLEN_P(z_args[0]));
} else if(!strcasecmp(Z_STRVAL_P(z_args[0]), "load")) {
- // Make sure we have a second argument, and it's not empty. If it is
- // empty, we can just return an empty array (which is what Redis does)
+ /* Make sure we have a second argument, and it's not empty. If it is */
+ /* empty, we can just return an empty array (which is what Redis does) */
if(argc < 2 || Z_TYPE_P(z_args[1]) != IS_STRING || Z_STRLEN_P(z_args[1]) < 1) {
- // Free our args
+ /* Free our args */
efree(z_args);
RETURN_FALSE;
}
- // Format our SCRIPT LOAD command
+ /* Format our SCRIPT LOAD command */
cmd_len = redis_cmd_format_static(&cmd, "SCRIPT", "ss", "LOAD", 4, Z_STRVAL_P(z_args[1]), Z_STRLEN_P(z_args[1]));
} else if(!strcasecmp(Z_STRVAL_P(z_args[0]), "exists")) {
- // Construct our SCRIPT EXISTS command
+ /* Construct our SCRIPT EXISTS command */
cmd_len = redis_build_script_exists_cmd(&cmd, &(z_args[1]), argc-1);
} else {
- // Unknown directive
+ /* Unknown directive */
efree(z_args);
RETURN_FALSE;
}
- // Free our alocated arguments
+ /* Free our alocated arguments */
efree(z_args);
- // Kick off our request
+ /* Kick off our request */
REDIS_PROCESS_REQUEST(redis_sock, cmd, cmd_len);
IF_ATOMIC() {
if(redis_read_variant_reply(INTERNAL_FUNCTION_PARAM_PASSTHRU, redis_sock, NULL) < 0) {
@@ -6541,23 +6541,23 @@ PHP_METHOD(Redis, dump) {
char *cmd, *key;
int cmd_len, key_len, key_free;
- // Parse our arguments
+ /* Parse our arguments */
if(zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", &object, redis_ce,
&key, &key_len) == FAILURE) {
RETURN_FALSE;
}
- // Grab our socket
+ /* Grab our socket */
if(redis_sock_get(object, &redis_sock TSRMLS_CC, 0) < 0) {
RETURN_FALSE;
}
- // Prefix our key if we need to
+ /* Prefix our key if we need to */
key_free = redis_key_prefix(redis_sock, &key, &key_len TSRMLS_CC);
cmd_len = redis_cmd_format_static(&cmd, "DUMP", "s", key, key_len);
if(key_free) efree(key);
- // Kick off our request
+ /* Kick off our request */
REDIS_PROCESS_REQUEST(redis_sock, cmd, cmd_len);
IF_ATOMIC() {
redis_ping_response(INTERNAL_FUNCTION_PARAM_PASSTHRU, redis_sock, NULL, NULL);
@@ -6575,23 +6575,23 @@ PHP_METHOD(Redis, restore) {
int cmd_len, key_len, value_len, key_free;
long ttl;
- // Parse our arguments
+ /* Parse our arguments */
if(zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Osls", &object, redis_ce,
&key, &key_len, &ttl, &value, &value_len) == FAILURE) {
RETURN_FALSE;
}
- // Grab our socket
+ /* Grab our socket */
if(redis_sock_get(object, &redis_sock TSRMLS_CC, 0) < 0) {
RETURN_FALSE;
}
- // Prefix the key if we need to
+ /* Prefix the key if we need to */
key_free = redis_key_prefix(redis_sock, &key, &key_len TSRMLS_CC);
cmd_len = redis_cmd_format_static(&cmd, "RESTORE", "sls", key, key_len, ttl, value, value_len);
if(key_free) efree(key);
- // Kick off our restore request
+ /* Kick off our restore request */
REDIS_PROCESS_REQUEST(redis_sock, cmd, cmd_len);
IF_ATOMIC() {
redis_boolean_response(INTERNAL_FUNCTION_PARAM_PASSTHRU, redis_sock, NULL, NULL);
@@ -6610,22 +6610,22 @@ PHP_METHOD(Redis, migrate) {
zend_bool copy=0, replace=0;
long port, dest_db, timeout;
- // Parse arguments
+ /* Parse arguments */
if(zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Oslsll|bb", &object, redis_ce,
&host, &host_len, &port, &key, &key_len, &dest_db, &timeout,
&copy, &replace) == FAILURE) {
RETURN_FALSE;
}
- // Grabg our socket
+ /* Grabg our socket */
if(redis_sock_get(object, &redis_sock TSRMLS_CC, 0) < 0) {
RETURN_FALSE;
}
- // Prefix our key if we need to, build our command
+ /* Prefix our key if we need to, build our command */
key_free = redis_key_prefix(redis_sock, &key, &key_len TSRMLS_CC);
- // Construct our command
+ /* Construct our command */
if(copy && replace) {
cmd_len = redis_cmd_format_static(&cmd, "MIGRATE", "sdsddss", host, host_len, port,
key, key_len, dest_db, timeout, "COPY",
@@ -6643,10 +6643,10 @@ PHP_METHOD(Redis, migrate) {
key, key_len, dest_db, timeout);
}
- // Free our key if we prefixed it
+ /* Free our key if we prefixed it */
if(key_free) efree(key);
- // Kick off our MIGRATE request
+ /* Kick off our MIGRATE request */
REDIS_PROCESS_REQUEST(redis_sock, cmd, cmd_len);
IF_ATOMIC() {
redis_boolean_response(INTERNAL_FUNCTION_PARAM_PASSTHRU, redis_sock, NULL, NULL);
@@ -6663,17 +6663,17 @@ PHP_METHOD(Redis, _prefix) {
char *key;
int key_len;
- // Parse our arguments
+ /* Parse our arguments */
if(zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", &object, redis_ce,
&key, &key_len) == FAILURE) {
RETURN_FALSE;
}
- // Grab socket
+ /* Grab socket */
if(redis_sock_get(object, &redis_sock TSRMLS_CC, 0) < 0) {
RETURN_FALSE;
}
- // Prefix our key if we need to
+ /* Prefix our key if we need to */
if(redis_sock->prefix != NULL && redis_sock->prefix_len > 0) {
redis_key_prefix(redis_sock, &key, &key_len TSRMLS_CC);
RETURN_STRINGL(key, key_len, 0);
@@ -6692,22 +6692,22 @@ PHP_METHOD(Redis, _serialize) {
char *val;
int val_len;
- // Parse arguments
+ /* Parse arguments */
if(zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Oz",
&object, redis_ce, &z_val) == FAILURE)
{
RETURN_FALSE;
}
- // Grab socket
+ /* Grab socket */
if(redis_sock_get(object, &redis_sock TSRMLS_CC, 0) < 0) {
RETURN_FALSE;
}
- // Serialize, which will return a value even if no serializer is set
+ /* Serialize, which will return a value even if no serializer is set */
redis_serialize(redis_sock, z_val, &val, &val_len TSRMLS_CC);
- // Return serialized value. Tell PHP to make a copy as some can be interned.
+ /* Return serialized value. Tell PHP to make a copy as some can be interned. */
RETVAL_STRINGL(val, val_len, 1);
STR_FREE(val);
}
@@ -6721,27 +6721,27 @@ PHP_METHOD(Redis, _unserialize) {
char *value;
int value_len;
- // Parse our arguments
+ /* Parse our arguments */
if(zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", &object, redis_ce,
&value, &value_len) == FAILURE) {
RETURN_FALSE;
}
- // Grab socket
+ /* Grab socket */
if(redis_sock_get(object, &redis_sock TSRMLS_CC, 0) < 0) {
RETURN_FALSE;
}
- // We only need to attempt unserialization if we have a serializer running
+ /* We only need to attempt unserialization if we have a serializer running */
if(redis_sock->serializer != REDIS_SERIALIZER_NONE) {
zval *z_ret = NULL;
if(redis_unserialize(redis_sock, value, value_len, &z_ret TSRMLS_CC) == 0) {
- // Badly formed input, throw an execption
+ /* Badly formed input, throw an execption */
zend_throw_exception(redis_exception_ce, "Invalid serialized data, or unserialization error", 0 TSRMLS_CC);
RETURN_FALSE;
}
RETURN_ZVAL(z_ret, 0, 1);
} else {
- // Just return the value that was passed to us
+ /* Just return the value that was passed to us */
RETURN_STRINGL(value, value_len, 1);
}
}
@@ -6753,16 +6753,16 @@ PHP_METHOD(Redis, getLastError) {
zval *object;
RedisSock *redis_sock;
- // Grab our object
+ /* Grab our object */
if(zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &object, redis_ce) == FAILURE) {
RETURN_FALSE;
}
- // Grab socket
+ /* Grab socket */
if(redis_sock_get(object, &redis_sock TSRMLS_CC, 0) < 0) {
RETURN_FALSE;
}
- // Return our last error or NULL if we don't have one
+ /* Return our last error or NULL if we don't have one */
if(redis_sock->err != NULL && redis_sock->err_len > 0) {
RETURN_STRINGL(redis_sock->err, redis_sock->err_len, 1);
} else {
@@ -6777,16 +6777,16 @@ PHP_METHOD(Redis, clearLastError) {
zval *object;
RedisSock *redis_sock;
- // Grab our object
+ /* Grab our object */
if(zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &object, redis_ce) == FAILURE) {
RETURN_FALSE;
}
- // Grab socket
+ /* Grab socket */
if(redis_sock_get(object, &redis_sock TSRMLS_CC, 0) < 0) {
RETURN_FALSE;
}
- // Clear error message
+ /* Clear error message */
if(redis_sock->err) {
efree(redis_sock->err);
}
@@ -6805,19 +6805,19 @@ PHP_METHOD(Redis, time) {
char *cmd;
int cmd_len;
- // Grab our object
+ /* Grab our object */
if(zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &object, redis_ce) == FAILURE) {
RETURN_FALSE;
}
- // Grab socket
+ /* Grab socket */
if(redis_sock_get(object, &redis_sock TSRMLS_CC, 0) < 0) {
RETURN_FALSE;
}
- // Build TIME command
+ /* Build TIME command */
cmd_len = redis_cmd_format_static(&cmd, "TIME", "");
- // Execute or queue command
+ /* Execute or queue command */
REDIS_PROCESS_REQUEST(redis_sock, cmd, cmd_len);
IF_ATOMIC() {
if(redis_sock_read_multibulk_reply_raw(INTERNAL_FUNCTION_PARAM_PASSTHRU, redis_sock, NULL, NULL) < 0) {
@@ -6864,7 +6864,7 @@ PHP_METHOD(Redis, getPort) {
RedisSock *redis_sock;
if((redis_sock = redis_sock_get_connected(INTERNAL_FUNCTION_PARAM_PASSTHRU))) {
- // Return our port
+ /* Return our port */
RETURN_LONG(redis_sock->port);
} else {
RETURN_FALSE;
@@ -6878,7 +6878,7 @@ PHP_METHOD(Redis, getDBNum) {
RedisSock *redis_sock;
if((redis_sock = redis_sock_get_connected(INTERNAL_FUNCTION_PARAM_PASSTHRU))) {
- // Return our db number
+ /* Return our db number */
RETURN_LONG(redis_sock->dbNumber);
} else {
RETURN_FALSE;
@@ -6957,19 +6957,19 @@ PHP_METHOD(Redis, client) {
char *cmd, *opt=NULL, *arg=NULL;
int cmd_len, opt_len, arg_len;
- // Parse our method parameters
+ /* Parse our method parameters */
if(zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os|s",
&object, redis_ce, &opt, &opt_len, &arg, &arg_len) == FAILURE)
{
RETURN_FALSE;
}
- // Grab our socket
+ /* Grab our socket */
if(redis_sock_get(object, &redis_sock TSRMLS_CC, 0) < 0) {
RETURN_FALSE;
}
- // Build our CLIENT command
+ /* Build our CLIENT command */
if(ZEND_NUM_ARGS() == 2) {
cmd_len = redis_cmd_format_static(&cmd, "CLIENT", "ss", opt, opt_len,
arg, arg_len);
@@ -6977,10 +6977,10 @@ PHP_METHOD(Redis, client) {
cmd_len = redis_cmd_format_static(&cmd, "CLIENT", "s", opt, opt_len);
}
- // Execute our queue command
+ /* Execute our queue command */
REDIS_PROCESS_REQUEST(redis_sock, cmd, cmd_len);
- // We handle CLIENT LIST with a custom response function
+ /* We handle CLIENT LIST with a custom response function */
if(!strncasecmp(opt, "list", 4)) {
IF_ATOMIC() {
redis_client_list_reply(INTERNAL_FUNCTION_PARAM_PASSTHRU,redis_sock,NULL);
@@ -7004,11 +7004,11 @@ redis_build_scan_cmd(char **cmd, REDIS_SCAN_TYPE type, char *key, int key_len,
char *keyword;
int arg_count, cmd_len;
- // Count our arguments +1 for key if it's got one, and + 2 for pattern
- // or count given that they each carry keywords with them.
+ /* Count our arguments +1 for key if it's got one, and + 2 for pattern */
+ /* or count given that they each carry keywords with them. */
arg_count = 1 + (key_len>0) + (pattern_len>0?2:0) + (count>0?2:0);
- // Turn our type into a keyword
+ /* Turn our type into a keyword */
switch(type) {
case TYPE_SCAN:
keyword = "SCAN";
@@ -7025,30 +7025,30 @@ redis_build_scan_cmd(char **cmd, REDIS_SCAN_TYPE type, char *key, int key_len,
break;
}
- // Start the command
+ /* Start the command */
cmd_len = redis_cmd_format_header(cmd, keyword, arg_count);
- // Add the key in question if we have one
+ /* Add the key in question if we have one */
if(key_len) {
cmd_len = redis_cmd_append_str(cmd, cmd_len, key, key_len);
}
- // Add our iterator
+ /* Add our iterator */
cmd_len = redis_cmd_append_int(cmd, cmd_len, iter);
- // Append COUNT if we've got it
+ /* Append COUNT if we've got it */
if(count) {
cmd_len = redis_cmd_append_str(cmd, cmd_len, "COUNT", sizeof("COUNT")-1);
cmd_len = redis_cmd_append_int(cmd, cmd_len, count);
}
- // Append MATCH if we've got it
+ /* Append MATCH if we've got it */
if(pattern_len) {
cmd_len = redis_cmd_append_str(cmd, cmd_len, "MATCH", sizeof("MATCH")-1);
cmd_len = redis_cmd_append_str(cmd, cmd_len, pattern, pattern_len);
}
- // Return our command length
+ /* Return our command length */
return cmd_len;
}
@@ -7064,9 +7064,9 @@ generic_scan_cmd(INTERNAL_FUNCTION_PARAMETERS, REDIS_SCAN_TYPE type) {
int cmd_len, key_len=0, pattern_len=0, num_elements, key_free=0;
long count=0, iter;
- // Different prototype depending on if this is a key based scan
+ /* Different prototype depending on if this is a key based scan */
if(type != TYPE_SCAN) {
- // Requires a key
+ /* Requires a key */
if(zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Osz/|s!l",
&object, redis_ce, &key, &key_len, &z_iter,
&pattern, &pattern_len, &count)==FAILURE)
@@ -7074,7 +7074,7 @@ generic_scan_cmd(INTERNAL_FUNCTION_PARAMETERS, REDIS_SCAN_TYPE type) {
RETURN_FALSE;
}
} else {
- // Doesn't require a key
+ /* Doesn't require a key */
if(zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Oz/|s!l",
&object, redis_ce, &z_iter, &pattern, &pattern_len,
&count) == FAILURE)
@@ -7083,32 +7083,32 @@ generic_scan_cmd(INTERNAL_FUNCTION_PARAMETERS, REDIS_SCAN_TYPE type) {
}
}
- // Grab our socket
+ /* Grab our socket */
if(redis_sock_get(object, &redis_sock TSRMLS_CC, 0) < 0) {
RETURN_FALSE;
}
- // Calling this in a pipeline makes no sense
+ /* Calling this in a pipeline makes no sense */
IF_NOT_ATOMIC() {
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Can't call SCAN commands in multi or pipeline mode!");
RETURN_FALSE;
}
- // The iterator should be passed in as NULL for the first iteration, but we can treat
- // any NON LONG value as NULL for these purposes as we've seperated the variable anyway.
+ /* The iterator should be passed in as NULL for the first iteration, but we can treat */
+ /* any NON LONG value as NULL for these purposes as we've seperated the variable anyway. */
if(Z_TYPE_P(z_iter) != IS_LONG || Z_LVAL_P(z_iter)<0) {
- // Convert to long
+ /* Convert to long */
convert_to_long(z_iter);
iter = 0;
} else if(Z_LVAL_P(z_iter)!=0) {
- // Update our iterator value for the next passthru
+ /* Update our iterator value for the next passthru */
iter = Z_LVAL_P(z_iter);
} else {
- // We're done, back to iterator zero
+ /* We're done, back to iterator zero */
RETURN_FALSE;
}
- // Prefix our key if we've got one and we have a prefix set
+ /* Prefix our key if we've got one and we have a prefix set */
if(key_len) {
key_free = redis_key_prefix(redis_sock, &key, &key_len TSRMLS_CC);
}
@@ -7121,11 +7121,11 @@ generic_scan_cmd(INTERNAL_FUNCTION_PARAMETERS, REDIS_SCAN_TYPE type) {
* an updated iterator.
*/
do {
- // Format our SCAN command
+ /* Format our SCAN command */
cmd_len = redis_build_scan_cmd(&cmd, type, key, key_len, (int)iter,
pattern, pattern_len, count);
- // Execute our command getting our new iterator value
+ /* Execute our command getting our new iterator value */
REDIS_PROCESS_REQUEST(redis_sock, cmd, cmd_len);
if(redis_sock_read_scan_reply(INTERNAL_FUNCTION_PARAM_PASSTHRU,
redis_sock,type,&iter)<0)
@@ -7134,15 +7134,15 @@ generic_scan_cmd(INTERNAL_FUNCTION_PARAMETERS, REDIS_SCAN_TYPE type) {
RETURN_FALSE;
}
- // Get the number of elements
+ /* Get the number of elements */
hash = Z_ARRVAL_P(return_value);
num_elements = zend_hash_num_elements(hash);
} while(redis_sock->scan == REDIS_SCAN_RETRY && iter != 0 && num_elements == 0);
- // Free our key if it was prefixed
+ /* Free our key if it was prefixed */
if(key_free) efree(key);
- // Update our iterator reference
+ /* Update our iterator reference */
Z_LVAL_P(z_iter) = iter;
}
diff --git a/redis_array.c b/redis_array.c
index e9a56e7a..05f0c2e4 100644
--- a/redis_array.c
+++ b/redis_array.c
@@ -85,7 +85,7 @@ zend_function_entry redis_array_functions[] = {
static void redis_array_free(RedisArray *ra) {
int i;
- // Redis objects
+ /* Redis objects */
for(i=0;i<ra->count;i++) {
zval_dtor(ra->redis[i]);
efree(ra->redis[i]);
@@ -110,7 +110,7 @@ static void redis_array_free(RedisArray *ra) {
zval_dtor(ra->z_pure_cmds);
efree(ra->z_pure_cmds);
- // Free structure itself
+ /* Free structure itself */
efree(ra);
}