Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add prefix support to SUBSCRIBE/PSUBSCRIBE

Now the Redis::OPT_PREFIX will apply to subscribe/psubscribe
channels and will be applied before searching for messages.
  • Loading branch information...
commit d247bb68185e14082c40fe38066844aea22964a6 1 parent 00ff68d
Michael Grunder michael-grunder authored
Showing with 17 additions and 3 deletions.
  1. +17 −3 redis.c
20 redis.c
View
@@ -5283,8 +5283,8 @@ PHPAPI void generic_subscribe_cmd(INTERNAL_FUNCTION_PARAMETERS, char *sub_cmd)
HashTable *arr_hash;
HashPosition pointer;
RedisSock *redis_sock;
- char *cmd = "", *old_cmd = NULL;
- int cmd_len, array_count;
+ char *cmd = "", *old_cmd = NULL, *key;
+ int cmd_len, array_count, key_len, key_free;
zval *z_tab, **tmp;
char *type_response;
@@ -5319,10 +5319,24 @@ PHPAPI void generic_subscribe_cmd(INTERNAL_FUNCTION_PARAMETERS, char *sub_cmd)
if(*cmd) {
old_cmd = cmd;
}
- cmd_len = spprintf(&cmd, 0, "%s %s", cmd, Z_STRVAL_PP(data));
+
+ // Grab our key and len
+ key = Z_STRVAL_PP(data);
+ key_len = Z_STRLEN_PP(data);
+
+ // 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);
+
if(old_cmd) {
efree(old_cmd);
}
+
+ // Free our key if it was prefixed
+ if(key_free) {
+ efree(key);
+ }
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.