Sanity check please! PHP/memcached strategy

Dustin Sallings dustin at
Sat Oct 27 02:24:34 UTC 2007

   It's roughly the same thing. If you are building a map of ids to  
records, you just do one bulk pass through memcached, and another with  
a single SQL query.  I'd expect you'd have one more reusable function  
that dumps the results from the query into the cache.

Dustin Sallings (mobile)

On Oct 26, 2007, at 17:17, mike <mike503 at> wrote:

> On 10/26/07, Dustin Sallings <dustin at> wrote:
>>   Pipelining won't help when you're waiting for the response to one
>> before sending a second request.
>>   Note that you'd also do 50 db requests with your current code.  The
>> trick is to group them sensibly.
>>   After you find out what IDs you need, ask for them all at once.
>> Figure out which ones you didnt get (set difference) and do a db  
>> query
>> with an "in" clause for all of those at once.  Then set them
>> individually back into the cache.
> yeah, i was expecting a hit of 50 queries at once, but after that
> there should be zero for that set.
> does anyone have any example code when dealing with lists like this?
> just build an array of IDs, and then do some sort of
> asset_multiget($array) which does a cache_multiget of the IDs, ...
> hmm. that gets confusing then. because i will need to track
> hits/misses. that's why i think i liked the single row approach,
> because hits and misses can be mixed and i am none the wiser...
> i'd be curious (and grateful) to see anyone's approaches which seem
> appropriate to deal with a multiple get/multiple row matches...
> thanks!

More information about the memcached mailing list