Forums / General / which lib to use with memcache

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

eZ debug

Timing: Jan 29 2025 23:45:54
Script start
Timing: Jan 29 2025 23:45:54
Module start 'content'
Timing: Jan 29 2025 23:45:54
Module end 'content'
Timing: Jan 29 2025 23:45:54
Script end

Main resources:

Total runtime0.1162 sec
Peak memory usage2,048.0000 KB
Database Queries141

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0063 587.9219180.8438
Module start 'content' 0.00630.0062 768.765697.9609
Module end 'content' 0.01250.1037 866.7266526.0234
Script end 0.1162  1,392.7500 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00322.7803200.0002
Check MTime0.00131.1537200.0001
Mysql Total
Database connection0.00070.622110.0007
Mysqli_queries0.077866.92381410.0006
Looping result0.00090.73811390.0000
Template Total0.103488.910.1034
Template load0.00080.726010.0008
Template processing0.102588.188010.1025
Override
Cache load0.00060.479910.0006
Sytem overhead
Fetch class attribute can translate value0.00050.421510.0005
XML
Image XML parsing0.00030.298410.0003
General
dbfile0.00574.9375200.0003
String conversion0.00000.004330.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/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