[OpenSIPS-Users] Localcache issue

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


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}) >= $(avp(s:a){s.int}) ) {

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




More information about the Users mailing list