<span class="Apple-style-span" style="font-family: arial, helvetica, sans-serif;"><span class="Apple-style-span" style="font-size: small;">Hey All,</span></span><div><span class="Apple-style-span" style="font-family: arial, helvetica, sans-serif;"><span class="Apple-style-span" style="font-size: small;">I just had this revelation today about a potential feature and I wanted to run it by the group to see if there was any interest in it. I tried posting it to the tracker, but <a href="http://sf.net">sf.net</a> keeps failing (I'm getting server busy messages.. grumble..)</span></span></div>
<div><span class="Apple-style-span" style="font-family: arial, helvetica, sans-serif;"><span class="Apple-style-span" style="font-size: small;"><br></span></span></div><div><span class="Apple-style-span" style="font-family: arial, helvetica, sans-serif;"><span class="Apple-style-span" style="font-size: small;">So I had talked before about "memcache families". This is where you can store data into separate memcache namespaces. This would be useful to store and purge large sets for data at one time..</span></span></div>
<div><span class="Apple-style-span" style="font-family: arial, helvetica, sans-serif;"><span class="Apple-style-span" style="font-size: small;"><br></span></span></div><div><span class="Apple-style-span" style="font-family: arial, helvetica, sans-serif;"><span class="Apple-style-span" style="font-size: small;">Think for a minute about routes being loaded into memcache....</span></span></div>
<div><span class="Apple-style-span" style="font-family: arial, helvetica, sans-serif;"><span class="Apple-style-span" style="font-size: small;"><br></span></span></div><div><span class="Apple-style-span" style="font-family: arial, helvetica, sans-serif;"><span class="Apple-style-span" style="font-size: small;">Say for example, if I had 10 customers. Each with their own unique route table with 3 million records each. As one table, that would be 30 million total routes.. Which may be slow to traverse (not sure, haven't tested). However if each route table is in it's own family (ie: namespace in memcache) it would only be 3 million. Which should be very fast. Also, if I'm changing just one route, I wouldn't have to purge my entire memcache store to update it.. just the one route table effected.. Also, I use memcache to store my IP to account relationships.. so we don't need those to reload either.. That's the idea of memcache families; only update the family that makes sense. It would only add one additional option to the cache_store and cache_fetch functions (family). And would also add a function cache_family_purge, which would delete an entire family of data.</span></span></div>
<div><span class="Apple-style-span" style="font-family: arial, helvetica, sans-serif;"><span class="Apple-style-span" style="font-size: small;"><br></span></span></div><div><span class="Apple-style-span" style="font-family: arial, helvetica, sans-serif;"><span class="Apple-style-span" style="font-size: small;">Now building on that idea is my next feature request (which really doesn't depend on memcache families, but it makes sense to combine the two):</span></span></div>
<span class="Apple-style-span" style="white-space: pre-wrap; "><span class="Apple-style-span" style="font-family: arial, helvetica, sans-serif;"><span class="Apple-style-span" style="font-size: small;"><div>This is a request for the ability to "find_best_match" in memcache family. This is a function that you'd pass a memcache family to and it would take the input value (say $rU for example) and keep removing a character from it until it hit a match and then return the cached value. Of course, this also depends on preloaded cache values. Which I'd load from an external script upon startup.<br>
</div>
Function usage would be like this:
find_best_match("<memcache_storage_engine>","<memcache_family_name>","<value_to_search_with>",<avp_to_recieve_results>)
<br></span></span></span><span class="Apple-style-span" style="white-space: pre-wrap; ">There is a *ton* that can be done with this.. My mind is spinning. :)
ie: return 1.2.3.4_<prefix>
Then use the transformations to pull the prefix out and push it into the $rU.. Very powerful.. And you wouldn't even need custom modules anymore for routing.
</span><div><span class="Apple-style-span" style="white-space: pre-wrap; "> </span><br></div><div><span class="Apple-style-span" style="white-space: pre-wrap; "><span class="Apple-style-span" style="font-family: arial, helvetica, sans-serif;"><span class="Apple-style-span" style="font-size: small;">So if the dialed number is 5125551212 and in memcache I have:
512555 -> 1.2.3.4
It would hit memcache like this:
if (find_best_match("local","$avp(s:routetable)","$rU",$avp(s:routestring))) {
$rD = $(avp(s:routestring){s.select,0,_}); # rewrite destination
$rU = $rU + $(avp(s:routestring){s.select,1,_}); # add prefix if defined
} else {
sl_send_reply("404","No Route");
exit;
}
5125551212 -> No Match
512555121 -> No Match
51255512 -> No Match
5125551 -> No Match
512555 -> 1.2.3.4
</span></span></span><div><span class="Apple-style-span" style="font-family: arial, helvetica, sans-serif;"><span class="Apple-style-span" style="font-size: small;"> </span></span></div><div>Thanks for your consideration and feedback!!</div>
<div>-Brett</div><div><br></div></div>