<div dir="ltr"><font color="#000099"><font size="2">Thanks Bogdan,</font></font><div><font color="#000099"><font size="2">I already figure it up, I used :$var(max-reg)=$(avp(s:max-reg){<a href="http://s.int?by-user=t" target="_top" rel="nofollow" link="external">s.int</a>}); to convert the value.</font></font></div>

<div><font class="Apple-style-span" color="#000099">But this issue is still weird, how come when the first use the AVP, the function works, but on the next time, when I&#39;m getting the value from the cache, the function fails and I need to convert the values?</font></div>

<div><font class="Apple-style-span" color="#000099"><br></font></div><div><font class="Apple-style-span" color="#000099">Yaniv</font></div><div><div dir="ltr"><span style="font-family:arial, sans-serif;font-size:13px"><span style="font-size:medium"><span><strong><span><span><span><span style="color:rgb(255, 153, 0)"><div>

<span style="font-family:arial, sans-serif;font-size:13px"><span style="font-size:medium"><span><strong><span><span><span><span style="color:rgb(255, 153, 0)"><br></span></span></span></span></strong></span></span></span></div>

<div><span style="font-family:arial, sans-serif;font-size:13px"><span style="font-size:medium"><span><strong><span><span><span><span style="color:rgb(255, 153, 0)"></span></span></span></span></strong></span></span></span></div>

<div><span style="font-family:arial, sans-serif;font-size:13px"><span style="font-size:medium"><span><strong><span><span><span><span style="color:rgb(255, 153, 0)"></span></span></span></span></strong></span></span></span><span style="color:rgb(0, 0, 0);font-weight:normal"><strong><span><span><span><span style="color:rgb(255, 153, 0)">Yaniv Vaknin</span></span></span></span></strong></span></div>

</span></span></span></span></strong></span></span><span style="font-size:medium"><br><span style="color:rgb(0, 0, 255)"><strong>Mobile:</strong></span> 972-524-525065<br><span style="color:rgb(0, 0, 255)"><strong>Office:</strong></span> 972-722-772299<br>

<strong><span style="color:rgb(0, 0, 255)">Email</span><a title="Yaniv@shahar-tech.com" href="http://Yaniv@shahar-tech.com/" style="color:rgb(28, 81, 168)" target="_blank" rel="nofollow" link="external">:</a></strong><a href="/user/SendEmail.jtp?type=node&node=5558395&i=0" target="_top" rel="nofollow">[hidden email]</a> <br>

<span style="color:rgb(0, 0, 255)"><strong>Site:</strong></span><a title="http://www.shahar-tech.com" href="http://www.shahar-tech.com/" style="color:rgb(28, 81, 168)" target="_blank" rel="nofollow" link="external">http://www.shahar-tech.com</a></span></span><div>

<span style="font-family:arial, sans-serif;font-size:13px"><br></span></div></div><br>
<br><br><div class="gmail_quote">On Wed, Sep 22, 2010 at 11:40 AM, Bogdan-Andrei Iancu [via OpenSIPS (Open SIP Server)] <span dir="ltr">&lt;<a href="/user/SendEmail.jtp?type=node&node=5558395&i=1" target="_top" rel="nofollow">[hidden email]</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

Hi Yaniv,
<br><br>Yaniv Vaknin wrote:
<div><div class='shrinkable-quote'><br>&gt; Hi,
<br>&gt; I&#39;m using localcache module to store some variables, the module works great
<br>&gt; but i noticed an issue when performing value check on the AVP&#39;s.
<br>&gt; I&#39;m trying to check if the value of the AVP is bigger then a value:
<br>&gt;
<br>&gt; if(!cache_fetch(&quot;local&quot;,&quot;a_$fd&quot;,$avp(s:a))){
<br>&gt; avp_db_query(&quot;select `a` from table where domain=&#39;$fd&#39;&quot;,&quot;$avp(s:a)&quot;);
<br>&gt; cache_store(&quot;local&quot;,&quot;a_$fd&quot;,&quot;$avp(s:a)&quot;,3600)
<br>&gt;
<br>&gt; }else{
<br>&gt; cache_fetch(&quot;local&quot;,&quot;a_$fd&quot;,$avp(s:a))
<br>&gt;   
</div>why do you do fetch again here? you already did it once in the &quot;if&quot; 
</div>condition
<br>&gt; avp_db_query(&quot;select count(*)  FROM `location` WHERE `domain`= &#39;$fd&#39;
<br>&gt; &quot;,&quot;$avp(s:cur-reg);&quot;);
<br>&gt; if(avp_check(&quot;$avp(s:cur-reg)&quot;,&quot;ge/$avp(s:a)&quot;)){
<br>&gt;   
<br>replace this with the much straight forward:
<br>       if ( $avp(s:cur-reg) &gt;= $avp(s:a) ) {
<br><br>But note that the values must be INT to compare. The avp_db_query() 
<br>return STR all the time, so you might use some transformation to convert 
<br>to int :
<br>       if ( $(avp(s:cur-reg){<a href="http://s.int?by-user=t" target="_blank" rel="nofollow" link="external">s.int</a>}) &gt;= $(avp(s:a){<a href="http://s.int?by-user=t" target="_blank" rel="nofollow" link="external">s.int</a>}) ) {
<br><br>Regards,
<br>Bogdan
<br><div><div class='shrinkable-quote'><br>&gt; On the first time that I run the check, everything works fine, but on the
<br>&gt; second time, when the server uses the cache_fetch value the avp_check fails
<br>&gt; (give the wrong result)
<br>&gt; I tried setting the avp to int and also played with the avp_check command
<br>&gt; (add /g or /i to the command), I even tried :
<br>&gt;  if($avp(s:cur-reg) &gt; $avp(s:a))
<br>&gt; But the result is always the same, I guess that I&#39;m doing something the
<br>&gt; wrong way, but I can&#39;t figure what...
<br>&gt; the version I&#39;m using is 1.6.2...
<br>&gt;
<br>&gt; Thanks,
<br>&gt; Yaniv Vaknin
<br>&gt;   
</div></div><br>-- 
<br>Bogdan-Andrei Iancu
<br>OpenSIPS Bootcamp
<br>15 - 19 November 2010, Edison, New Jersey, USA
<br><a href="http://www.voice-system.ro?by-user=t" target="_blank" rel="nofollow" link="external">www.voice-system.ro</a>
<br><br><br>_______________________________________________
<br>Users mailing list
<br><a href="http://user/SendEmail.jtp?type=node&amp;node=5558338&amp;i=0" rel="nofollow" target="_blank" link="external">[hidden email]</a>
<br><a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users" rel="nofollow" link="external" target="_blank">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a><br>
<br><br>
<hr noshade size="1" color="#cccccc">
<div style="color:#666666;font:11px tahoma,geneva,helvetica,arial,sans-serif">
View message @ <a href="http://opensips-open-sip-server.1449251.n2.nabble.com/Localcache-issue-tp5523216p5558338.html?by-user=t" target="_blank" rel="nofollow" link="external">http://opensips-open-sip-server.1449251.n2.nabble.com/Localcache-issue-tp5523216p5558338.html</a>

<br>To unsubscribe from Localcache issue, <a href="http://opensips-open-sip-server.1449251.n2.nabble.com/template/TplServlet.jtp?tpl=unsubscribe_by_code&amp;node=5523216&amp;code=eWFuaXZAc2hhaGFyLXRlY2guY29tfDU1MjMyMTZ8MTMzOTg4MDAzMg==&by-user=t" target="_blank" rel="nofollow" link="external">click here</a>.
</div>
<br>
</blockquote></div><br></div></div>

<br><hr align="left" width="300">
View this message in context: <a href="http://opensips-open-sip-server.1449251.n2.nabble.com/Localcache-issue-tp5523216p5558395.html">Re: Localcache issue</a><br>
Sent from the <a href="http://opensips-open-sip-server.1449251.n2.nabble.com/OpenSIPS-Users-f1449235.html">OpenSIPS - Users mailing list archive</a> at Nabble.com.<br>