which lib to use with memcache

Author Message

Stéphane Couzinier

Thursday 23 April 2009 9:13:13 am

Hi

There are 2 lib to deal with memcache server:
http://fr.php.net/memcache/
http://fr.php.net/memcached

memcached look better but it's a beta version.

Somebody have test it?

http://www.kouz-cooking.fr

André R.

Thursday 23 April 2009 2:31:35 pm

No, but what about witing a small class with functions that wrap around these functions and do code you'll need for you as well. Makes it easier to switch back and forth, you can also change it to write to db if you want to... :P

eZ Online Editor 5: http://projects.ez.no/ezoe || eZJSCore (Ajax): http://projects.ez.no/ezjscore || eZ Publish EE http://ez.no/eZPublish/eZ-Publish-Enterprise-Subscription
@: http://twitter.com/andrerom

Stéphane Couzinier

Thursday 23 April 2009 2:58:01 pm

Salut andré

We will do something like this but it's a bit difficult to test correctly memcache.(simulate a lof of traffic. the server never work a lot;-) )
The beta version memcached have better function than the stable one but it's a beta version...

http://www.kouz-cooking.fr

André R.

Friday 24 April 2009 12:42:34 am

I would maybe aim at the beta, so the abstractions include the functions you have there witch can be very valuable ( :append, ::setMulti and ::setMultiByKey among others...).

So the abstraction would be like

public function append( $key, $value )
{
    if ( $this->mem !== null )
    {
        $this->mem->append( $key, $value );
        return true;
    }
    return false;
}

So if you need to downgrade because of instability you would hav to do something like:

public function append( $key, $value )
{
    if ( $this->mem !== null )
    {
        $currentValue = $this->mem->get( $key );
        if ( $currentValue === false )
            $this->mem->set( $key, $value );
        else
            $this->mem->set( $key, $currentValue . $value );
        return true;
    }
    return false;
}

I suggest a object approach to the abstraction class, perferably with a singleton pattern ( stMemCache::getInstance() -> self::$instance === null -> protected function __construct() -> return self::$instance; ).
But it can just as well be done on a all static class, where you call stMemCache::init() first to set self::$mem (instead of $this->mem).

Sorry that I can't really answear your first question on what to choose, any one here who have tried Memcached?

eZ Online Editor 5: http://projects.ez.no/ezoe || eZJSCore (Ajax): http://projects.ez.no/ezjscore || eZ Publish EE http://ez.no/eZPublish/eZ-Publish-Enterprise-Subscription
@: http://twitter.com/andrerom

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 30 2025 19:40:40
Script start
Timing: Jan 30 2025 19:40:40
Module start 'layout'
Timing: Jan 30 2025 19:40:40
Module start 'content'
Timing: Jan 30 2025 19:40:40
Module end 'content'
Timing: Jan 30 2025 19:40:40
Script end

Main resources:

Total runtime0.0276 sec
Peak memory usage6,144.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0052 588.1250151.2109
Module start 'layout' 0.00520.0042 739.3359220.6875
Module start 'content' 0.00940.0160 960.02341,001.8828
Module end 'content' 0.02540.0022 1,961.906333.9922
Script end 0.0276  1,995.8984 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.003512.5619140.0002
Check MTime0.00134.6656140.0001
Mysql Total
Database connection0.00072.706410.0007
Mysqli_queries0.003010.841130.0010
Looping result0.00000.051010.0000
Template Total0.00134.610.0013
Template load0.00103.587510.0010
Template processing0.00031.018510.0003
Override
Cache load0.00072.442110.0007
General
dbfile0.002910.465380.0004
String conversion0.00000.025140.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs