Ignore:
Timestamp:
Jun 8, 2006 5:36:10 AM (18 years ago)
Author:
scdev
Message:

${1}

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/Cache.inc.php

    r153 r154  
    4747    function Cache($namespace='')
    4848    {
    49         $this->_ns = '_cache' . $namespace;
    50        
    51         if (!isset($_SESSION[$this->_ns])) {
     49        $this->_ns = $namespace;
     50       
     51        if (!isset($_SESSION['_cache'][$this->_ns])) {
    5252            $this->clear();
    5353        }
     
    146146
    147147        // Remove any value already stored under this key.
    148         unset($_SESSION[$this->_ns][$keyhash]);
     148        unset($_SESSION['_cache'][$this->_ns][$keyhash]);
    149149
    150150        // Continue to prune the cache if its size is greater than stack_size_limit, but keep at least min_items.
    151         while (strlen(serialize($_SESSION[$this->_ns])) + $var_len >= $this->getParam('stack_size_limit') && sizeof($_SESSION[$this->_ns]) >= $this->getParam('min_items')) {
    152             array_shift($_SESSION[$this->_ns]);
     151        while (strlen(serialize($_SESSION['_cache'][$this->_ns])) + $var_len >= $this->getParam('stack_size_limit') && sizeof($_SESSION['_cache'][$this->_ns]) >= $this->getParam('min_items')) {
     152            array_shift($_SESSION['_cache'][$this->_ns]);
    153153        }
    154154
    155155        // Save this value under the specified key.
    156         $_SESSION[$this->_ns][$keyhash] =& $var;
     156        $_SESSION['_cache'][$this->_ns][$keyhash] =& $var;
    157157
    158158        if ($var_len >= 1024000) {
     
    182182
    183183        $keyhash = md5($key);
    184         if (isset($_SESSION[$this->_ns][$keyhash])) {
     184        if (isset($_SESSION['_cache'][$this->_ns][$keyhash])) {
    185185            $app->logMsg(sprintf('Retreiving %s from cache.', $key), LOG_DEBUG, __FILE__, __LINE__);
    186186            // Move the accessed cached datum to the top of the stack. Maybe somebody knows a better way to do this?
    187             $tmp =& $_SESSION[$this->_ns][$keyhash];
    188             unset($_SESSION[$this->_ns][$keyhash]);
    189             $_SESSION[$this->_ns][$keyhash] =& $tmp;
     187            $tmp =& $_SESSION['_cache'][$this->_ns][$keyhash];
     188            unset($_SESSION['_cache'][$this->_ns][$keyhash]);
     189            $_SESSION['_cache'][$this->_ns][$keyhash] =& $tmp;
    190190            // Return the unserialized datum.
    191             return unserialize($_SESSION[$this->_ns][$keyhash]);
     191            return unserialize($_SESSION['_cache'][$this->_ns][$keyhash]);
    192192        } else {
    193193            return false;
     
    208208
    209209        $keyhash = md5($key);
    210         return array_key_exists($keyhash, $_SESSION[$this->_ns]);
     210        return array_key_exists($keyhash, $_SESSION['_cache'][$this->_ns]);
    211211    }
    212212
     
    220220    {
    221221        $keyhash = md5($key);
    222         unset($_SESSION[$this->_ns][$keyhash]);
     222        unset($_SESSION['_cache'][$this->_ns][$keyhash]);
    223223    }
    224224   
     
    233233    function clear()
    234234    {
    235         $_SESSION[$this->_ns] = array();
     235        $_SESSION['_cache'][$this->_ns] = array();
    236236    }
    237237
Note: See TracChangeset for help on using the changeset viewer.