Hello,
here comes attached a patch to add array support for ndb_redis module.
This patch is based on parts of sqlops module.
it maintains old options: $redis->type and $redis->value, but for arrays there are new options enabled.
$redis->size - returns number of array elements.
$redis->type[n] - returns type of nth array element.
$redis->value[n] - returns value of nth array element.
$redis->type - returns array type as in hiredis.h
$redis->value - returns null for arrays.
Regards, Vicente.
PS: This is my first patch to the list. Any criticism is welcome!
On 03/30/2012 11:47 AM, Daniel-Constantin Mierla wrote:
Hello,
indeed redis connector is dealing string and integer values by now.
Extending it for dealing with arrays will be useful, proposed variant looks good for me. If you are going to contribute a patch, it will be accepted (and appreciated).
Cheers, Daniel
On 3/29/12 8:14 PM, Vicente Hernando wrote:
Hello,
I am studying the use case when a redis command returns an array (REDIS_REPLY_ARRAY type in hiredis.h from https://github.com/antirez/hiredis )
Function pv_get_redisc in kamailio/modules/ndb_redis/ndb_redis_mod.c : 365 returns a pv_value_t structure and currently only deals with REDIS_REPLY_STRING and REDIS_REPLY_INTEGER cases.
It seems looking at pvar.h that pv_value_t structure does not deal with arrays. Is that correct? So returning an array is not an option...
Then a better aproach could be changing pv_parse_redisc_name function:
right now from README in ndb_redis: after executing redis_cmd("srvN", "SET foo bar", "r"); I could get $redis(r->type) and $redis(r->value)
it could be a good idea to add options like: $redis(r->size) and $redis(r->value[Number]) when changing pv_parse_redisk_name function.
Do you think of that as a good approach?
Thanks in advance! Vicente.
sr-dev mailing list sr-dev@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev