Ignore:
Timestamp:
Jun 18, 2006 8:50:35 AM (18 years ago)
Author:
scdev
Message:

Q - added move method to ACL class, added polish.

File:
1 edited

Legend:

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

    r172 r174  
    117117
    118118    /**
    119      * Stores a new variable in the session cache. The $key is is md5'ed
    120      * because if a key is numeric, the array_shift function
    121      * will reset the key to the next largest int key. Weird behavior I can't
    122      * understand. For example $cache["123"] will become $cache[0]
     119     * Stores a new variable in the session cache. The $key should not be numberic
     120     * because the array_shift function will reset the key to the next largest
     121     * int key. Weird behavior I can't understand. For example $cache["123"] will become $cache[0]
    123122     *
    124123     * @param str   $key        An identifier for the cached object.
     
    138137        }
    139138
    140         $keyhash = md5($key);
    141139        $var = serialize($var);
    142140        $var_len = strlen($var);
     
    153151
    154152        // Remove any value already stored under this key.
    155         unset($_SESSION['_cache'][$this->_ns][$keyhash]);
     153        unset($_SESSION['_cache'][$this->_ns][$key]);
    156154
    157155        // Continue to prune the cache if its size is greater than stack_size_limit, but keep at least min_items.
     
    161159
    162160        // Save this value under the specified key.
    163         $_SESSION['_cache'][$this->_ns][$keyhash] =& $var;
     161        $_SESSION['_cache'][$this->_ns][$key] =& $var;
    164162
    165163        if ($var_len >= 1024000) {
     
    188186        }
    189187
    190         $keyhash = md5($key);
    191         if (isset($_SESSION['_cache'][$this->_ns][$keyhash])) {
     188        if (isset($_SESSION['_cache'][$this->_ns][$key])) {
    192189            $app->logMsg(sprintf('Retreiving %s from cache.', $key), LOG_DEBUG, __FILE__, __LINE__);
    193190            // Move the accessed cached datum to the top of the stack. Maybe somebody knows a better way to do this?
    194             $tmp =& $_SESSION['_cache'][$this->_ns][$keyhash];
    195             unset($_SESSION['_cache'][$this->_ns][$keyhash]);
    196             $_SESSION['_cache'][$this->_ns][$keyhash] =& $tmp;
     191            $tmp =& $_SESSION['_cache'][$this->_ns][$key];
     192            unset($_SESSION['_cache'][$this->_ns][$key]);
     193            $_SESSION['_cache'][$this->_ns][$key] =& $tmp;
    197194            // Return the unserialized datum.
    198             return unserialize($_SESSION['_cache'][$this->_ns][$keyhash]);
     195            return unserialize($_SESSION['_cache'][$this->_ns][$key]);
    199196        } else {
    200197            $app->logMsg(sprintf('Missing %s from cache.', $key), LOG_DEBUG, __FILE__, __LINE__);
     
    215212        }
    216213
    217         $keyhash = md5($key);
    218         return array_key_exists($keyhash, $_SESSION['_cache'][$this->_ns]);
     214        return array_key_exists($key, $_SESSION['_cache'][$this->_ns]);
    219215    }
    220216
     
    227223    function delete($key)
    228224    {
    229         $keyhash = md5($key);
    230         unset($_SESSION['_cache'][$this->_ns][$keyhash]);
     225        unset($_SESSION['_cache'][$this->_ns][$key]);
    231226    }
    232227   
Note: See TracChangeset for help on using the changeset viewer.