diff options
author | Nicolas Favre-Felix <n.favrefelix@gmail.com> | 2011-09-14 01:59:14 +0400 |
---|---|---|
committer | Nicolas Favre-Felix <n.favrefelix@gmail.com> | 2011-09-14 01:59:14 +0400 |
commit | 38f2992576e748acd5a298187ba487ef2817f286 (patch) | |
tree | e311fe56dd3fe3a3881d10a799200cd87a3e3acd /redis_array.c | |
parent | 50c86a1cbaeaaa12cb3025c290e6ab4c914451d0 (diff) |
Changed DEL to use index when available.
Diffstat (limited to 'redis_array.c')
-rw-r--r-- | redis_array.c | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/redis_array.c b/redis_array.c index 34e2bb11..9ce9d558 100644 --- a/redis_array.c +++ b/redis_array.c @@ -892,6 +892,7 @@ PHP_METHOD(RedisArray, del) /* calls */ for(n = 0; n < ra->count; ++n) { /* for each node */ + int found = 0; redis_inst = ra->redis[n]; /* copy args */ @@ -906,14 +907,32 @@ PHP_METHOD(RedisArray, del) INIT_PZVAL(z_tmp); add_next_index_zval(z_argarray, z_tmp); + found++; + } + + if(!found) { // don't run empty DELs + zval_dtor(z_argarray); + efree(z_argarray); + continue; + } + + if(ra->index) { /* add MULTI */ + ra_index_multi(redis_inst TSRMLS_CC); } /* call */ MAKE_STD_ZVAL(z_ret); - call_user_function(&redis_ce->function_table, &ra->redis[n], + call_user_function(&redis_ce->function_table, &redis_inst, &z_fun, z_ret, 1, &z_argarray TSRMLS_CC); - total += Z_LVAL_P(z_ret); /* increment total */ + if(ra->index) { + ra_index_del(z_argarray, redis_inst TSRMLS_CC); /* use SREM to remove keys from node index */ + ra_index_exec(redis_inst, z_tmp, 0 TSRMLS_CC); /* run EXEC */ + total += Z_LVAL_P(z_tmp); /* increment total from multi/exec block */ + } else { + total += Z_LVAL_P(z_ret); /* increment total from single command */ + } + zval_dtor(z_ret); efree(z_ret); |