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:
authormichael-grunder <michael.grunder@gmail.com>2014-06-19 16:34:10 +0400
committermichael-grunder <michael.grunder@gmail.com>2015-05-06 01:02:04 +0300
commit4b3e05714922f6a89c261ab9ea5fe1d96386c554 (patch)
tree758119d2a6861da0bc3d975b90473823d90209e6 /cluster_library.c
parent36e78540a65bc00361f71b33c5af0fdd33131afd (diff)
DEL command implemented
Modified our MSET handler and made it generic (it has the same general mechanism as DEL, just with a different return type) and implemented the DEL command. We've got the same consideration to make. What to do in the event of a catastrophic failure.
Diffstat (limited to 'cluster_library.c')
-rw-r--r--cluster_library.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/cluster_library.c b/cluster_library.c
index 282419e8..4b0a7a99 100644
--- a/cluster_library.c
+++ b/cluster_library.c
@@ -1721,6 +1721,35 @@ PHPAPI void cluster_msetnx_resp(INTERNAL_FUNCTION_PARAMETERS, redisCluster *c,
efree(mctx);
}
+/* Handler for DEL */
+PHPAPI void cluster_del_resp(INTERNAL_FUNCTION_PARAMETERS, redisCluster *c,
+ void *ctx)
+{
+ clusterMultiCtx *mctx = (clusterMultiCtx*)ctx;
+
+ // If we get an invalid reply, inform the client
+ if(c->reply_type != TYPE_INT) {
+ php_error_docref(0 TSRMLS_CC, E_WARNING,
+ "Invalid reply type returned for DEL command");
+ efree(mctx);
+ return;
+ }
+
+ // Increment by the number of keys deleted
+ Z_LVAL_P(mctx->z_multi) += c->reply_len;
+
+ if(mctx->last) {
+ if(CLUSTER_IS_ATOMIC(c)) {
+ ZVAL_LONG(return_value, Z_LVAL_P(mctx->z_multi));
+ } else {
+ add_next_index_long(c->multi_resp, Z_LVAL_P(mctx->z_multi));
+ }
+ efree(mctx->z_multi);
+ }
+
+ efree(ctx);
+}
+
/* Handler for MSET */
PHPAPI void cluster_mset_resp(INTERNAL_FUNCTION_PARAMETERS, redisCluster *c,
void *ctx)