[SR-Users] How to detect there are no matching subscriber for uri

Daniel-Constantin Mierla miconda at gmail.com
Tue Feb 12 10:24:11 CET 2013


Hello,

On 2/10/13 2:43 PM, Krishna Kurapati wrote:
> Hi,
>
> When we receive an request, we do "
>
> lookup("location") call to find if the uri is there or not.
>
> There are two scenarios:
>
> 1. The aor is in the subscriber table but  not in usrloc table
> 2. The aor is not in subscriber table
>
> I would like to respond differently to the sender in each of these 
> cases. Right now, the lookup returns -1 for either case. Is there any 
> other way other than dipping into database each time?
the subscriber table is not cached by default, so you need to query the 
database unless you build some custom caching.

For database query, uri_db has some function to do the check, but sqlops 
can be used as well.

For caching at startup, if the user ids are numbers, mtree is an option, 
otherwise htable. htable can be used as temporary/dynamic cache, like 
adding the entry there for a defined interval after querying the 
database, so next time is a chance to hit the cache rather than going 
again to database.

Other options, usually when working with blocks of numbers, is to do 
some regexp checks that would reduce the probability to hit database for 
invalid user ids.

Cheers,
Daniel

-- 
Daniel-Constantin Mierla - http://www.asipto.com
http://twitter.com/#!/miconda - http://www.linkedin.com/in/miconda
Kamailio World Conference, April 16-17, 2013, Berlin
  - http://conference.kamailio.com -




More information about the sr-users mailing list