[OpenSIPS-Users] Localcache issue

Bogdan-Andrei Iancu bogdan at voice-system.ro
Wed Sep 22 12:11:25 CEST 2010


Yaniv,

in your original script, the max-reg AVP was loaded and tested only when 
data was found in cache.......

Regards,
Bogdan

Yaniv Vaknin wrote:
> Thanks Bogdan,
> I already figure it up, I used :$var(max-reg)=$(avp(s:max-reg){s.int 
> <http://s.int?by-user=t>}); to convert the value.
> But this issue is still weird, how come when the first use the AVP, 
> the function works, but on the next time, when I'm getting the value 
> from the cache, the function fails and I need to convert the values?
>
> Yaniv
> *
> *
> *
> **
> ***Yaniv Vaknin*
> *
> *Mobile:* 972-524-525065
> *Office:* 972-722-772299
> *Email: <http://Yaniv@shahar-tech.com/>*[hidden email] 
> </user/SendEmail.jtp?type=node&node=5558395&i=0> 
> *Site:*http://www.shahar-tech.com <http://www.shahar-tech.com/>
>
>
>
>
> On Wed, Sep 22, 2010 at 11:40 AM, Bogdan-Andrei Iancu [via OpenSIPS 
> (Open SIP Server)] <[hidden email] 
> </user/SendEmail.jtp?type=node&node=5558395&i=1>> wrote:
>
>     Hi Yaniv,
>
>     Yaniv Vaknin wrote:
>
>     > Hi,
>     > I'm using localcache module to store some variables, the module
>     works great
>     > but i noticed an issue when performing value check on the AVP's.
>     > I'm trying to check if the value of the AVP is bigger then a value:
>     >
>     > if(!cache_fetch("local","a_$fd",$avp(s:a))){
>     > avp_db_query("select `a` from table where
>     domain='$fd'","$avp(s:a)");
>     > cache_store("local","a_$fd","$avp(s:a)",3600)
>     >
>     > }else{
>     > cache_fetch("local","a_$fd",$avp(s:a))
>     >  
>     why do you do fetch again here? you already did it once in the "if"
>     condition
>     > avp_db_query("select count(*)  FROM `location` WHERE `domain`=
>     '$fd'
>     > ","$avp(s:cur-reg);");
>     > if(avp_check("$avp(s:cur-reg)","ge/$avp(s:a)")){
>     >  
>     replace this with the much straight forward:
>            if ( $avp(s:cur-reg) >= $avp(s:a) ) {
>
>     But note that the values must be INT to compare. The avp_db_query()
>     return STR all the time, so you might use some transformation to
>     convert
>     to int :
>            if ( $(avp(s:cur-reg){s.int <http://s.int?by-user=t>}) >=
>     $(avp(s:a){s.int <http://s.int?by-user=t>}) ) {
>
>     Regards,
>     Bogdan
>
>     > On the first time that I run the check, everything works fine,
>     but on the
>     > second time, when the server uses the cache_fetch value the
>     avp_check fails
>     > (give the wrong result)
>     > I tried setting the avp to int and also played with the
>     avp_check command
>     > (add /g or /i to the command), I even tried :
>     >  if($avp(s:cur-reg) > $avp(s:a))
>     > But the result is always the same, I guess that I'm doing
>     something the
>     > wrong way, but I can't figure what...
>     > the version I'm using is 1.6.2...
>     >
>     > Thanks,
>     > Yaniv Vaknin
>     >  
>
>     -- 
>     Bogdan-Andrei Iancu
>     OpenSIPS Bootcamp
>     15 - 19 November 2010, Edison, New Jersey, USA
>     www.voice-system.ro <http://www.voice-system.ro?by-user=t>
>
>
>     _______________________________________________
>     Users mailing list
>     [hidden email] <http://user/SendEmail.jtp?type=node&node=5558338&i=0>
>     http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>
>
>     ------------------------------------------------------------------------
>     View message @
>     http://opensips-open-sip-server.1449251.n2.nabble.com/Localcache-issue-tp5523216p5558338.html
>     <http://opensips-open-sip-server.1449251.n2.nabble.com/Localcache-issue-tp5523216p5558338.html?by-user=t>
>
>     To unsubscribe from Localcache issue, click here
>     <http://opensips-open-sip-server.1449251.n2.nabble.com/template/TplServlet.jtp?tpl=unsubscribe_by_code&node=5523216&code=eWFuaXZAc2hhaGFyLXRlY2guY29tfDU1MjMyMTZ8MTMzOTg4MDAzMg==&by-user=t>.
>
>
>
>
> ------------------------------------------------------------------------
> View this message in context: Re: Localcache issue 
> <http://opensips-open-sip-server.1449251.n2.nabble.com/Localcache-issue-tp5523216p5558395.html>
> Sent from the OpenSIPS - Users mailing list archive 
> <http://opensips-open-sip-server.1449251.n2.nabble.com/OpenSIPS-Users-f1449235.html> 
> at Nabble.com.
> ------------------------------------------------------------------------
>
> _______________________________________________
> Users mailing list
> Users at lists.opensips.org
> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>   


-- 
Bogdan-Andrei Iancu
OpenSIPS Bootcamp
15 - 19 November 2010, Edison, New Jersey, USA
www.voice-system.ro




More information about the Users mailing list