Memcached dialplan function
January 30, 2008 – 8:59 amCreation of an func_memcached dialplan Function. This has it’s advantages over the built in DB structure in that it’s all in memory and it can be hit by other servers as well to retrieve the same information (”network ready”).Memcached Libraries are at: http://www.danga.com/memcached/(pardon my syntax.. from memory here..)For example:
exten => s,1,Set(VMBOX=${MEMCACHEGET('vmbox-5125551212') })
exten => s,n,VoiceMail(${VMBOX})
Or perhaps more useful (although check with your local provider before doing this to determine if you are allowed):
exten => s,1,Set(CALLERNAME=${MEMCACHEGET('CNAME-5125551212')})
exten => s,n,GotoIf($["${CALLERNAME}x" = "x"]?getname)
exten => s,n(setname),Set(CALLERID(name)=${CALLERNAME})
exten => s,n,Goto(performdial)
exten => s,n(getname),Set(CALLERNAME=${CURL(http://myNameServer/someapp.php?number=${EXTEN})})
exten => s,n,MEMCACHESET('CNAME-${EXTEN}' ,${CALLERNAME})
exten => s,n, Goto(setname)
exten => s,n(performdial),Dial(..........)
……IE: Check the cache. If it exists, use it.. If not, retrieve it, set it, use it.. Next time it exists. Oops, forgot to mention, memcached has a mechanism to auto expire stale items as well.. Which is really nice..-Brett

You must be logged in to post a comment.