Multiget/intelligent generic PHP wrapper function... thoughts /advice wanted

Dustin Sallings dustin at
Sat Nov 3 17:57:15 UTC 2007

   Most of this discussion has been around guessing what is or isn't  
fast enough.  Knuth warned us about wasting our time on such things.

   My python function figured out what keys were not returned in one  
line that (at least I think) is easy to read.  I'm sure a similar  
thing is possible in PHP.  The rest of that function was reusable for  
any similar lookup one might want to do.  The sample DB fill source  
was safe from SQL injections, DB independent, and easy to understand.

   These should be the goals in designing software.  A good design  
usually leads to an implementation that is fast enough.

   Iff you have strong evidence that your implementation is not fast  
enough, then you begin to trade simplicity for speed.  Most code never  
needs to make it to this phase.

   So please don't consider the length of this thread to indicate the  
complexity of the problem, but more of people's desire to  
unnecessarily add complexity to solutions.

Dustin Sallings (mobile)

On Nov 3, 2007, at 7:31, Brian Beuning <BBeuning at> wrote:

> It seems to me getting this code right is a little tricky.
> Just look at how long the thread has been.
> To me that is a strong argument to add support for returning
> the missing keys from the memcached API.
> That way each user of memcached does not need to figure out
> how to keep tack of not found keys.
> Brian Beuning
> -----Original Message-----
> From: mike
> To: Chris Goffinet
> Cc: Memcached List
> Sent: 11/3/2007 12:47 AM
> Subject: Re: Multiget/intelligent generic PHP wrapper function...
> thoughts/advice wanted
> Yeah, apologies to all for going a little deeper OT.
> I was planning on replying just to Chris, but thought I'd keep it in
> on the list in case someone else cared.
> Thanks for the pointers Chris, I am going with this code for now
> (using the $dontcare=>$key in the loop) and will see how the app
> works.
> On 11/2/07, Chris Goffinet <goffinet at> wrote:
>> Yes I know that, hoping you could fix the code with the $key=>$value
>> change.
>> Array_keys is not clean because your simply calling an unneeded
>> function on an already good array? Why on earth would you waste
>> overhead (O(n)) when its simply on same line? ... I think this
>> discussion has went really off topic as its not relating to memcache
>> but more PHP.
>> Chris Goffinet
>> goffinet at
>> On Nov 2, 2007, at 10:28 PM, mike wrote:
>>> On 11/2/07, Chris Goffinet <goffinet at> wrote:
>>>> The array_values is not needed, its already an array. Just set it
> up
>>>> as $key=>$value and do not do extra overhead.
>>> Actually it would be:
>>> foreach($keys as $dontcare => $key) {
>>> But wouldn't
>>> foreach(array_keys($keys) as $key) { be just as clean?

More information about the memcached mailing list