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>2018-01-17 20:36:38 +0300
committermichael-grunder <michael.grunder@gmail.com>2018-01-17 20:36:38 +0300
commit9e65c429318d93bd37c9d42abf79709395e6e805 (patch)
tree379dc0f44cb4b7219eab0c4c31184f734f1d881d /redis_cluster.c
parent837dee471ccac86581d306594ee945e82027572f (diff)
Implement UNLINK command
This commit implements UNLINK for Redis, RedisCluster, and RedisArray. To a client library UNLINK behaves identically to DEL so we can use the same handlers for both.
Diffstat (limited to 'redis_cluster.c')
-rw-r--r--redis_cluster.c24
1 files changed, 19 insertions, 5 deletions
diff --git a/redis_cluster.c b/redis_cluster.c
index 95bcba40..ede16b94 100644
--- a/redis_cluster.c
+++ b/redis_cluster.c
@@ -244,6 +244,7 @@ zend_function_entry redis_cluster_functions[] = {
PHP_ME(RedisCluster, ttl, arginfo_key, ZEND_ACC_PUBLIC)
PHP_ME(RedisCluster, type, arginfo_key, ZEND_ACC_PUBLIC)
PHP_ME(RedisCluster, unsubscribe, arginfo_unsubscribe, ZEND_ACC_PUBLIC)
+ PHP_ME(RedisCluster, unlink, arginfo_del, ZEND_ACC_PUBLIC)
PHP_ME(RedisCluster, unwatch, arginfo_void, ZEND_ACC_PUBLIC)
PHP_ME(RedisCluster, watch, arginfo_watch, ZEND_ACC_PUBLIC)
PHP_ME(RedisCluster, zadd, arginfo_zadd, ZEND_ACC_PUBLIC)
@@ -708,7 +709,8 @@ static HashTable *method_args_to_ht(zval *z_args, int argc) {
return ht_ret;
}
-/* Handler for both MGET and DEL */
+/* Convienience handler for commands that take multiple keys such as
+ * MGET, DEL, and UNLINK */
static int cluster_mkey_cmd(INTERNAL_FUNCTION_PARAMETERS, char *kw, int kw_len,
zval *z_ret, cluster_cb cb)
{
@@ -935,8 +937,10 @@ static int cluster_mset_cmd(INTERNAL_FUNCTION_PARAMETERS, char *kw, int kw_len,
return 0;
}
-/* {{{ proto array RedisCluster::del(string key1, string key2, ... keyN) */
-PHP_METHOD(RedisCluster, del) {
+/* Generic passthru for DEL and UNLINK which act identically */
+static void cluster_generic_delete(INTERNAL_FUNCTION_PARAMETERS,
+ char *kw, int kw_len)
+{
zval *z_ret;
#if (PHP_MAJOR_VERSION < 7)
@@ -949,14 +953,24 @@ PHP_METHOD(RedisCluster, del) {
ZVAL_LONG(z_ret, 0);
// Parse args, process
- if(cluster_mkey_cmd(INTERNAL_FUNCTION_PARAM_PASSTHRU, "DEL",
- sizeof("DEL")-1, z_ret, cluster_del_resp)<0)
+ if(cluster_mkey_cmd(INTERNAL_FUNCTION_PARAM_PASSTHRU, kw, kw_len, z_ret,
+ cluster_del_resp) < 0)
{
efree(z_ret);
RETURN_FALSE;
}
}
+/* {{{ proto array RedisCluster::del(string key1, string key2, ... keyN) */
+PHP_METHOD(RedisCluster, del) {
+ cluster_generic_delete(INTERNAL_FUNCTION_PARAM_PASSTHRU, "DEL", sizeof("DEL") - 1);
+}
+
+/* {{{ proto array RedisCluster::unlink(string key1, string key2, ... keyN) */
+PHP_METHOD(RedisCluster, unlink) {
+ cluster_generic_delete(INTERNAL_FUNCTION_PARAM_PASSTHRU, "UNLINK", sizeof("UNLINK") - 1);
+}
+
/* {{{ proto array RedisCluster::mget(array keys) */
PHP_METHOD(RedisCluster, mget) {
zval *z_ret;