Thanks Brian. Your example helps.

JJ

On Fri, Aug 21, 2009 at 5:06 PM, Brian Moon <[email protected]> wrote:

>
> This example works like butter.  It also shows the speed.  The multi get
> returns all the data in the same microsecond.  At least, on my server.
>
> http://pastebin.ca/1538366
>
> Brian.
> --------
> http://brian.moonspot.net/
>
> On 8/21/09 5:11 PM, Jeremiah Jester wrote:
>
>> Brian,
>>
>> I just tried this implementation with an array of keys but am unable to
>> get things to work. Can you review my code below?
>>
>> <?PHP
>> $ip="x.x.x.x"; //omitted
>> $memcache=new Memcache;
>> $memcache->connect($ip,11211);
>> $art_keys=$memcache->get($data);
>> $articles=$memcache->get($art_keys);
>> print_r($articles)
>> ?>
>>
>> Print_r($articles) output results in the following: Array()
>>
>> Any thoughts?
>>
>> Note: $data contains the following array...
>>
>> Array ( [0] => 1250806616.459 [1] => 1250806742.147 [2] =>
>> 1250806879.394 [3] => 1250806945.325 [4] => 1250806973.403 [5] =>
>> 1250807216.495 [6] => 1250807346.296 [7] => 1250807544.351 [8] =>
>> 1250807704.403 [9] => 1250807893.019 [10] => 1250807909.371 [11] =>
>> 1250807977.352 [12] => 1250807998.257 [13] => 1250808035.941 [14] =>
>> 1250808065.689 [15] => 1250808082.764 [16] => 1250808111.094 [17] =>
>> 1250808186.522 [18] => 1250808212.955 [19] => 1250812389.799 [20] =>
>> 1250812749.806 [21] => 1250812761.030 [22] => 1250812789.844 )
>>
>>
>> Thanks,
>> JJ
>>
>> On Fri, Aug 21, 2009 at 12:04 PM, Brian Moon <[email protected]
>> <mailto:[email protected]>> wrote:
>>
>>
>>    So, the advantage really comes in to play when you retrieving
>>    hundreds or even thousands of keys to retrieve in one page request.
>>      For example, on the dealnews.com <http://dealnews.com> front page,
>>
>>    we show 100-200 articles.  Now, we don't use memcached for that
>>    (whole other philosophy in use there), but I can use it as an
>>    example.  Consider this code:
>>
>>    // get array of keys for front page articles
>>    $art_keys = $memcache->get("front_page_articles");
>>
>>    // PHP object takes an array to do multi gets
>>    $articles = $memcache->get($art_keys);
>>
>>    // now I have a whole array of articles in one call.
>>
>>    So, even with multiple memcached servers, I only need one call to
>>    each server for a whole set of keys.  Otherwise, I would have to
>>    grab lots of keys one at a time and that would be slower.  Much slower.
>>
>>    Brian.
>>    --------
>>    http://brian.moonspot.net/
>>
>>
>>    On 8/21/09 12:10 PM, Bill Moseley wrote:
>>
>>        I've often seen comments about using multi-gets for better
>>        performance.   First, I'm a bit curious if/why it's a big
>>        performance gain.
>>        Obviously, not all keys will be on the same memcached server in a
>>        multi-get request.  Can somoene give me the one short
>>        explanaition or
>>        point me to where to learn more?
>>
>>        I'm perhaps more curious how people use multiple gets -- or
>>        really the
>>        design of an web application that supports this.
>>
>>        I've tended to cache at a pretty low level -- that is if I have
>>        a method
>>        in the data model to fetch object "foo" I tend to check the
>>        cache, if
>>        not found then fetch from the database and save to memcached.  As a
>>        result we can end up with a lot of separate memcached get
>>        requests for a
>>        single web-request.  This is less true as the app becomes more
>>        web2.0-ish, but still happens.
>>
>>        So, I'm curious about the design of an application that supports
>>        gathering up a number of (perhaps unrelated) cache requests and
>>        fetch
>>        all at once.  Then fill in the cache where there are
>>        cache-misses.  Am I
>>        misunderstanding how people use this feature?
>>
>>
>>        --
>>        Bill Moseley
>>        [email protected] <mailto:[email protected]>
>>        <mailto:[email protected] <mailto:[email protected]>>
>>
>>
>>

Reply via email to