Changeset 39703 in spip-zone


Ignore:
Timestamp:
Aug 8, 2010, 3:53:07 PM (9 years ago)
Author:
fil@…
Message:

memoization pour les Object::Method(), pas seulement les function()

File:
1 edited

Legend:

Unmodified
Added
Removed
  • _plugins_/memoization/inc/memoization.php

    r32480 r39703  
    2424// (the function's variables are automatically taken into account)
    2525//
    26 // Usage: require_once 'xcache.php';
     26// Usage: include_spip('inc/memoization');
    2727// In any cacheable function add at top:
    2828// if(!is_null($c=cache_me())) return$c;
     
    3333                $trace = debug_backtrace();
    3434                $trace = $trace[1];
     35                if (isset($trace['object']))
     36                        $fun = array($trace['object'], $trace['function']);
     37                else
     38                        $fun = $trace['function'];
    3539                $key = md5(
    36                         $trace['function']
     40                        $fun
    3741                        .serialize($trace['args'])
    3842                        .serialize($vars)
     
    4044                if (!cache_isset($key)) {
    4145                        cache_set($key, null, $ttl);
    42                         $r = call_user_func_array($trace['function'], $trace['args']);
     46                        $r = call_user_func_array($fun, $trace['args']);
    4347                        cache_set($key, $r, $ttl);
    4448                        return $r;
Note: See TracChangeset for help on using the changeset viewer.