Conn =& $this->Application->GetADODBConnection(); $this->debugCache = $this->Application->isDebugMode() && dbg_ConstOn('DBG_CACHE'); } /** * Adds new value to cache $cache_name and identified by key $key * * @param string $cache_name cache name * @param int $key key name to add to cache * @param mixed $value value of chached record */ function setCache($cache_name, $key, $value) { $cache = $this->Get($cache_name, Array()); $cache[$key] = $value; $this->Set($cache_name, $cache); } /** * Returns cached $key value from cache named $cache_name * * @param string $cache_name cache name * @param int $key key name from cache * @return mixed */ function getCache($cache_name, $key) { $cache = $this->Get($cache_name, Array()); $ret = getArrayValue($cache, $key); $this->setStatistics($cache_name, $key, $ret); return $ret; } function setStatistics($cache_name, $key, $found) { if (!$this->debugCache) return true; if (!isset($this->statistics[$cache_name])) { $this->statistics[$cache_name] = Array(); } if (!isset($this->statistics[$cache_name][$key])) { $this->statistics[$cache_name][$key] = Array(); } $status_key = $found ? 'found' : 'not_found'; if (!isset($this->statistics[$cache_name][$key][$status_key])) { $this->statistics[$cache_name][$key][$status_key] = 0; } $this->statistics[$cache_name][$key][$status_key]++; } function printStatistics() { foreach ($this->statistics as $cache_name => $cache_data) { foreach ($cache_data as $key => $value) { if (!isset($value['found']) || $value['found'] == 1) { // remove cached records, that were used only 1 or 2 times unset($this->statistics[$cache_name][$key]); } } } print_pre($this->statistics); } } ?>