<div dir="ltr"><div><div><div>Hi,<br></div>I think cached attributes are like global variables, unique and valid in the whole Opensips execution. You can store them and fetch at any time regardless the message you are handling. So, as you suspect, the logic of the piece of code you showed will store for 1200s the value in cache for the first request that comes in. During this lifetime, any other subsequent request won&#39;t cause an update in its value. After 1200s the cached attribute will be deleted and the whole logic will repeat in the next request it receives.<br></div>Not sure why you tried to use the cache to store your domain, maybe because you need it later in your dialog. If this is the case rethink your logic and use dialog variables.<br><br></div>Patrick<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Dec 1, 2015 at 7:29 PM, Travis Manson-Drake <span dir="ltr">&lt;<a href="mailto:travism@simplybits.com" target="_blank">travism@simplybits.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">





<div link="#0563C1" vlink="#954F72" lang="EN-US">
<div>
<p class="MsoNormal">Hello Everyone!<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Hope you’re all doing well.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">I seem to be having an issue.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Basically I’m using OpenSIPS as a proxy that will receive request from UAC’s, then query a database to find out what Sipserver it belongs to then store the result with cachdb_local as an $avp variable, and finally modify the R-uri of the
 sip message to the UAC gets to the correct endpoint. I’ve got it working for the most part however I seem to be having an issue when I try to have multiple UAC’s hit the proxy.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">I think whats happening is the value stored in memchache is the first Sipserver the proxy gets a request for.
<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">For example:<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">If UAC1 sends a REGISTER to the proxy and the proxy finds out it belongs on SIPServ1 it then sets the AVP to sipserv1<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Now a few minutes later UAC2 comes along with a same REGISTER request but this time it belongs to SIPServ2, however this time it receives a 403 bad auth from sipserv2.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Here’s my current logic for DB query and memcache store:<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">NOTE: This is also in the REQUEST Route section of my logic, so this takes place before it hits any other routing logic.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">if(cache_fetch(&quot;local&quot;,&quot;PBX&quot;,$avp(PBX)))<u></u><u></u></p>
<p class="MsoNormal">                        {<u></u><u></u></p>
<p class="MsoNormal">                        $rd = $avp(PBX);<u></u><u></u></p>
<p class="MsoNormal">                        xlog(&quot;this is the value of the modified R-uri: $ru\n&quot;);<u></u><u></u></p>
<p class="MsoNormal">                        }<u></u><u></u></p>
<p class="MsoNormal">                else {<u></u><u></u></p>
<p class="MsoNormal">                        avp_db_query(&quot;select Servers.ipaddress from Servers where Servers.ID in (select phone.ServerID from phone where phone.mac in (select MAC FROM `phone_registrations` where auth_userid = &#39;$fU&#39;))&quot;, &quot;$avp(PBX)&quot;);<u></u><u></u></p>
<p class="MsoNormal">                        cache_store(&quot;local&quot;,&quot;PBX&quot;,&quot;$avp(PBX)&quot;,1200);<u></u><u></u></p>
<p class="MsoNormal">                     }<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Do you guys have any ideas on what I’m missing, or any advice?<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Thank you in advanced!<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal" style="line-height:115%"><b><span style="font-size:10.0pt;line-height:115%;font-family:&quot;Arial&quot;,sans-serif;color:navy">Travis Manson-Drake<u></u><u></u></span></b></p>
<p class="MsoNormal" style="line-height:115%"><b><span style="font-size:10.0pt;line-height:115%;font-family:&quot;Arial&quot;,sans-serif;color:navy">Voice Systems Analyst L1<u></u><u></u></span></b></p>
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:&quot;Arial&quot;,sans-serif;color:navy">Simply Bits, LLC</span></b><span style="font-size:12.0pt;font-family:&quot;Arial&quot;,sans-serif;color:navy"><u></u><u></u></span></p>
<p class="MsoNormal"><b><i><span style="font-size:8.0pt;font-family:&quot;Arial&quot;,sans-serif;color:#ffc000">Now You’re Thinkin’ Smart!</span></i></b><span style="font-family:&quot;Arial&quot;,sans-serif;color:navy"><u></u><u></u></span></p>
<p class="MsoNormal" style="line-height:115%"><span style="font-size:8.0pt;line-height:115%;font-family:&quot;Arial&quot;,sans-serif;color:navy">5225 N. Sabino Canyon Road
<br>
Tucson, AZ 85750<u></u><u></u></span></p>
<p class="MsoNormal" style="line-height:115%"><b><span style="font-size:8.0pt;line-height:115%;font-family:&quot;Arial&quot;,sans-serif;color:navy">Phone:</span></b><span style="font-size:8.0pt;line-height:115%;font-family:&quot;Arial&quot;,sans-serif;color:navy">
</span><span style="font-size:8.0pt;line-height:115%;font-family:&quot;Arial&quot;,sans-serif;color:#002060"><a href="tel:520-545-0311" value="+15205450311" target="_blank">520-545-0311</a></span><span style="font-size:8.0pt;line-height:115%;font-family:&quot;Arial&quot;,sans-serif;color:navy"><u></u><u></u></span></p>
<p class="MsoNormal" style="line-height:115%"><b><span style="font-size:8.0pt;line-height:115%;font-family:&quot;Arial&quot;,sans-serif;color:navy">Fax:</span></b><span style="font-size:8.0pt;line-height:115%;font-family:&quot;Arial&quot;,sans-serif;color:navy">
</span><span style="font-size:8.0pt;line-height:115%;font-family:&quot;Arial&quot;,sans-serif;color:#002060"><a href="tel:520-545-7252" value="+15205457252" target="_blank">520-545-7252</a><u></u><u></u></span></p>
<p class="MsoNormal" style="line-height:115%"><b><span style="font-size:8.0pt;line-height:115%;font-family:&quot;Arial&quot;,sans-serif;color:navy">Support Hotline</span></b><span style="font-size:8.0pt;line-height:115%;font-family:&quot;Arial&quot;,sans-serif;color:navy">:
</span><span style="font-size:8.0pt;line-height:115%;font-family:&quot;Arial&quot;,sans-serif;color:#002060"><a href="tel:5205450333" value="+15205450333" target="_blank">5205450333</a></span><span style="font-size:8.0pt;line-height:115%;font-family:&quot;Arial&quot;,sans-serif;color:navy"><u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-family:&quot;Arial&quot;,sans-serif;color:#1f497d"><a href="http://www.simplybits.com/" title="http://www.simplybits.com/" target="_blank"><span style="font-size:8.0pt;font-family:&quot;Times New Roman&quot;,serif;color:#0563c1">www.simplybits.com</span></a><u></u><u></u></span></p>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
</div>

<br>_______________________________________________<br>
Users mailing list<br>
<a href="mailto:Users@lists.opensips.org">Users@lists.opensips.org</a><br>
<a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users" rel="noreferrer" target="_blank">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a><br>
<br></blockquote></div><br></div>