<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; color: rgb(0, 0, 0); font-size: 14px; font-family: Calibri, sans-serif;">
<div>
<div>In on_reply_route all pseudo-variables are evaluated by default in the context of the reply, but in failure_route they are evaluated by default in the context of the request. I think you are probably getting a different value for $si than you are expecting
 in the failure_route case and there is no entry in the cache so it returns &lt;null&gt;. You can check this by printing your key values (&quot;bran$ci$rd” and &quot;bran$ci$si”)before each use to see if they are all the same. I think they will be different.</div>
<div><br>
</div>
<div>You can use the &lt;reply&gt; context, but I’m not sure if it will work for $si. See this:&nbsp;<a href="http://www.opensips.org/Documentation/Script-CoreVar-2-1">http://www.opensips.org/Documentation/Script-CoreVar-2-1</a></div>
<div>
<div id="MAC_OUTLOOK_SIGNATURE">
<div><br>
</div>
<div>Ben Newlin</div>
</div>
</div>
</div>
<div><br>
</div>
<span id="OLK_SRC_BODY_SECTION">
<div style="font-family:Calibri; font-size:12pt; text-align:left; color:black; BORDER-BOTTOM: medium none; BORDER-LEFT: medium none; PADDING-BOTTOM: 0in; PADDING-LEFT: 0in; PADDING-RIGHT: 0in; BORDER-TOP: #b5c4df 1pt solid; BORDER-RIGHT: medium none; PADDING-TOP: 3pt">
<span style="font-weight:bold">From: </span>&lt;<a href="mailto:users-bounces@lists.opensips.org">users-bounces@lists.opensips.org</a>&gt; on behalf of Arsen &lt;<a href="mailto:arsen.semionov@gmail.com">arsen.semionov@gmail.com</a>&gt;<br>
<span style="font-weight:bold">Reply-To: </span>OpenSIPS users mailling list &lt;<a href="mailto:users@lists.opensips.org">users@lists.opensips.org</a>&gt;<br>
<span style="font-weight:bold">Date: </span>Tuesday, March 29, 2016 at 11:08 AM<br>
<span style="font-weight:bold">To: </span>OpenSIPS users mailling list &lt;<a href="mailto:users@lists.opensips.org">users@lists.opensips.org</a>&gt;<br>
<span style="font-weight:bold">Subject: </span>[OpenSIPS-Users] cache_fetch on failure route issue<br>
</div>
<div><br>
</div>
<div>
<div>
<div dir="ltr">Hi guys,
<div><br>
</div>
<div>We have an issue with cache_fetch function.&nbsp;</div>
<div><br>
</div>
<div>In the per_branch_route I store destination numbers as following (we have multiple choice gateways here):</div>
<div><br>
</div>
<div>cache_store(&quot;local&quot;,&quot;bran$ci$rd&quot;,&quot;$rU&quot;,90);</div>
<div><br>
</div>
<div>In the on_reply_route in case of 200-OK I can successfully fetch the destination number:</div>
<div><br>
</div>
<div>cache_fetch(&quot;local&quot;,&quot;bran$ci$si&quot;, $avp(cached_dst));</div>
<div><br>
</div>
<div>But in case of the failed call the same function always return &lt;null&gt;<br clear="all">
<div><br>
</div>
<div>failure_route[FAILURE_REDIR] {</div>
<div><br>
</div>
<div>&nbsp; if (!t_check_status(&quot;[1|2|3][0-9][0-9]&quot;)) {<br>
</div>
<div><br>
</div>
<div>&nbsp; &nbsp; &nbsp;cache_fetch(&quot;local&quot;,&quot;bran$ci$si&quot;, $avp(cached_dst));</div>
<div><br>
</div>
<div>&nbsp; }</div>
<div><br>
</div>
<div>}</div>
<div><br>
</div>
<div>Can we use cache_fetch in the on_failure route?&nbsp;</div>
<div><br>
</div>
<div>Please advice</div>
<div><br>
</div>
<div>Thanks,</div>
<div><br>
</div>
-- <br>
<div class="gmail_signature">Regards,<br>
Arsen.<br>
</div>
</div>
</div>
</div>
</div>
</span>
</body>
</html>