[OpenSIPS-Users] Fwd: How to save avp-values to singal attribute name in cache_store?

Bogdan-Andrei Iancu bogdan at opensips.org
Wed Sep 21 11:47:51 CEST 2016


Hello Xiaofeng,

In your script, not sure if it is the indented behavior, but when 
looping through the loaded AVPs, you are pushing in cache the same key 
("domain") for all the values -> this will overwrite any previous value 
and you will end up storing only the last value.

The second "while" loop has no sense, as a key (in cache) has only one 
value (cannot be multiple).

Regards,

Bogdan-Andrei Iancu
OpenSIPS Founder and Developer
http://www.opensips-solutions.com

On 21.09.2016 12:09, xiaofeng wrote:
>
> On Tue, Sep 20, 2016 at 7:25 PM, Bogdan-Andrei Iancu 
> <bogdan at opensips.org <mailto:bogdan at opensips.org>> wrote:
> >
> > Hello,
> >
> > The avp_db_query() stores the DB result (multiple rows with multiple 
> columns) into a set of AVPs (kind of an array). See
> > http://www.opensips.org/html/docs/modules/2.2.x/avpops.html#id293973 
> <http://www.opensips.org/html/docs/modules/2.2.x/avpops.html#id293973>
> >
> > Using a while loop (see 
> http://www.opensips.org/Documentation/Script-Statements-2-2#toc3 
> <http://www.opensips.org/Documentation/Script-Statements-2-2#toc3>), 
> you can iterate throw all the rows, by checking the if 
> $(avp(xxx)[$var(idx)]) is NULL or not (where $var(idx) is the variable 
> in the while loop).
> >
> > Inside the loop, simply store the row (all the AVPs with that index) 
> into cache DB .
> >
> Just a example, if I understand what you mean:
> https://gist.github.com/was4444/ef203d871d5ed3b32144d41787862ac0 
> <https://gist.github.com/was4444/ef203d871d5ed3b32144d41787862ac0>
>
> It seems that we cannot fetch AVPs use `cache_fetch("local", 
> "attribute", $avp(values))` according to the document
> https://www.opensips.org/Documentation/Script-CoreFunctions-2-2#toc4 
> <https://www.opensips.org/Documentation/Script-CoreFunctions-2-2#toc4>
>
>
> Regards,
>
> xiaofeng
>
> --
> gpg key fingerprint:
> 2048R/5E63005B
> C84F 671F 70B7 7330 4726  5EC8 02BC CBA2 5E63 005B
> --
> _______________________________________________
> Users mailing list
> Users at lists.opensips.org <mailto:Users at lists.opensips.org>
> http://lists.opensips.org/cgi-bin/mailman/listinfo/users 
> <http://lists.opensips.org/cgi-bin/mailman/listinfo/users>
>
>
>
> -- 
> xiaofeng
>
> --
> gpg key fingerprint:
> 2048R/5E63005B
> C84F 671F 70B7 7330 4726  5EC8 02BC CBA2 5E63 005B
> --
> trans-zh_cn mailing list
> trans-zh_cn at lists.fedoraproject.org 
> <mailto:trans-zh_cn at lists.fedoraproject.org>
> https://admin.fedoraproject.org/mailman/listinfo/trans-zh_cn

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opensips.org/pipermail/users/attachments/20160921/000372de/attachment.htm>


More information about the Users mailing list