Ignore:
Timestamp:
Jun 7, 2006 8:41:19 PM (18 years ago)
Author:
scdev
Message:

Q - decided to use standard instantiation for Prefs and Cache instead of singleton methods.

File:
1 edited

Legend:

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

    r152 r153  
    131131        }
    132132
    133         $key = md5($key);
     133        $keyhash = md5($key);
    134134        $var = serialize($var);
    135135        $var_len = strlen($var);
     
    146146
    147147        // Remove any value already stored under this key.
    148         unset($_SESSION[$this->_ns][$key]);
     148        unset($_SESSION[$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.
     
    154154
    155155        // Save this value under the specified key.
    156         $_SESSION[$this->_ns][$key] =& $var;
     156        $_SESSION[$this->_ns][$keyhash] =& $var;
    157157
    158158        if ($var_len >= 1024000) {
     
    174174    function get($key)
    175175    {
     176        $app =& App::getInstance();
     177       
    176178        if (true !== $this->getParam('enabled')) {
    177             return false;
    178         }
    179 
    180         $key = md5($key);
    181         if (isset($_SESSION[$this->_ns][$key])) {
     179            $app->logMsg(sprintf('Cache not enabled, not getting data.', null), LOG_DEBUG, __FILE__, __LINE__);
     180            return false;
     181        }
     182
     183        $keyhash = md5($key);
     184        if (isset($_SESSION[$this->_ns][$keyhash])) {
     185            $app->logMsg(sprintf('Retreiving %s from cache.', $key), LOG_DEBUG, __FILE__, __LINE__);
    182186            // Move the accessed cached datum to the top of the stack. Maybe somebody knows a better way to do this?
    183             $tmp =& $_SESSION[$this->_ns][$key];
    184             unset($_SESSION[$this->_ns][$key]);
    185             $_SESSION[$this->_ns][$key] =& $tmp;
     187            $tmp =& $_SESSION[$this->_ns][$keyhash];
     188            unset($_SESSION[$this->_ns][$keyhash]);
     189            $_SESSION[$this->_ns][$keyhash] =& $tmp;
    186190            // Return the unserialized datum.
    187             return unserialize($_SESSION[$this->_ns][$key]);
     191            return unserialize($_SESSION[$this->_ns][$keyhash]);
    188192        } else {
    189193            return false;
     
    203207        }
    204208
    205         $key = md5($key);
    206         return array_key_exists($key, $_SESSION[$this->_ns]);
     209        $keyhash = md5($key);
     210        return array_key_exists($keyhash, $_SESSION[$this->_ns]);
    207211    }
    208212
     
    215219    function delete($key)
    216220    {
    217         $key = md5($key);
    218         unset($_SESSION[$this->_ns][$key]);
     221        $keyhash = md5($key);
     222        unset($_SESSION[$this->_ns][$keyhash]);
    219223    }
    220224   
Note: See TracChangeset for help on using the changeset viewer.