initialized = true; $this->_my_class_name = strtolower(get_class($this)); } /** * Set a given key/value pair within the cache * * @param string $key * @param mixed $value */ function set($key, $value) { if(EXTERNAL_CACHE_DEBUG) { SugarCache::log("Step 1: Adding key to {$GLOBALS['external_cache_type']} cache $key with value ($value)"); } if(empty($value)) { $value = EXTERNAL_CACHE_NULL_VALUE; } if(EXTERNAL_CACHE_DEBUG) { SugarCache::log("Step 2: Adding key to {$GLOBALS['external_cache_type']} cache $key with value ($value)"); } $this->_cache[$key] = $value; } /** * Retrieve the value of a given key * * @param string $key * @return mixed */ function get($key) { $GLOBALS['external_cache_request_local_total']++; if (isset($this->_cache[$key])) { if (EXTERNAL_CACHE_DEBUG) { SugarCache::log("BASE: found {$key}", 'lightpass'); } $GLOBALS['external_cache_request_local_hits']++; return $this->_cache[$key]; } else { if (EXTERNAL_CACHE_DEBUG) { $type = $this->_my_class_name == 'sugarcache_base' ? 'fail' : 'lightfail'; SugarCache::log("BASE: unable to locate {$key}", $type); } } } /** * Unset a given value * * @internal The term "unset" is a reserved word within PHP. This * opts for using the magic __unset() within PHP5 to enable * direct unset($cache->foo) calls. Due to BC considerations * with PHP 4, however, this method should be invoked * directly via $cache->__unset('foo'); * * @param string $key */ function __unset($key) { unset($this->_cache[$key]); } /** * Clean opcode cache */ function clean_opcodes() { /* nothing by default */ } }