Skip to content

Commit

Permalink
Initial commit of refactored command construction
Browse files Browse the repository at this point in the history
This commit adds a new printf like command construction function
with additionaly format specifiers specific to phpredis.  Because
phpredis can be configured to automatically prefix keys and/or
automatically serialize values we had a great deal of redundant
boilerplate code.

zend_parse_paramaters(..., "sz", &key, &keylen, &z_arg);
keyfree = redis_key_prefix(redis_sock, &key, &keylen);
valfree = redis_serialize(redis_sock, z_val, &realval, &reallen);
/* More processing */
if (keyfree) efree(key);
if (valfree) efree(val);

Now it is possible to use redis_spprintf and use format specifiers
specific to these tasks, which will handle prefixing or serialization
(as well as memory cleanup) automatically:

/* The library function will automatically prefix and serialize values
   if phpredis has been configured to do that */
len = phpredis_spprintf(redis_sock, slot TRMLS_CC, "SET", "kv", key,
                        key_len, z_value);
  • Loading branch information
michael-grunder committed Apr 26, 2017
1 parent 9ec9aed commit a4a0ed5
Show file tree
Hide file tree
Showing 5 changed files with 354 additions and 576 deletions.
Loading

0 comments on commit a4a0ed5

Please sign in to comment.