SourceForge has been redesigned. Learn more.

Turck MMCache API Enhancement Request

  • warwick Shaw

    warwick Shaw - 2003-06-20


    I have a number of php scripts stored within database rows.
    The code can easily be stored and retreived using Turck MMCache API and executed with eval.

    At the moment I have...
    if (!mmcache_get($objectid)) {
        $code = getObjectCodeFromDB($objectid);
        mmcache_put($objectid, $code, $ttl);
    } else {
        $code = join ('', mmcache_get($objectid));


    Alot of the php scripts are dynamic which return different results depending on when and who runs the code.

    What I like to do is avoid the eval($code) step and cache the $code as compiled bytecode in shared memory.
    Then execute the cached bytecode by supplying just the key($obejctid).

    so something like...

    if (!mmcache_get($objectid)) {
        $code = getObjectCodeFromDB($objectid);
        mmcache_store_as_bytecode($objectid, $code, $ttl);

    $result = mmcache_run($objectid);

    Thanks for a great program.


    • Dmitry Stogov

      Dmitry Stogov - 2003-06-21

      Use the function "mmcache_cache_result".

      $code = mmcache_cahce_result($objectid,"getObjectCodeFromDB($objectid);",$ttl);

      It doesn't caches bytecode, but may be I will do it in the future.


Log in to post a comment.