Index: branches/5.2.x/core/kernel/managers/cache_manager.php =================================================================== diff -u -N -r16664 -r16772 --- branches/5.2.x/core/kernel/managers/cache_manager.php (.../cache_manager.php) (revision 16664) +++ branches/5.2.x/core/kernel/managers/cache_manager.php (.../cache_manager.php) (revision 16772) @@ -1,6 +1,6 @@ settingTableName = TABLE_PREFIX . 'ConfigurationValues'; } } + + $this->maxCacheDuration = 60 * 60 * 24 * kUtil::getSystemConfig()->get('MaxCacheDuration', ''); } + /** * Creates caching manager instance * * @access public */ public function InitCache() { - $this->cacheHandler = $this->Application->makeClass('kCache'); + $this->cacheHandler = $this->Application->makeClass('kCache', array($this->maxCacheDuration)); } /** @@ -344,12 +354,12 @@ $cache_rebuild_by = SERVER_NAME . ' (' . $this->Application->getClientIp() . ') - ' . adodb_date('d/m/Y H:i:s'); if ($this->Application->isCachingType(CACHING_TYPE_MEMORY)) { - $this->Application->setCache('master:configs_parsed', serialize($cache)); - $this->Application->setCache('master:last_cache_rebuild', $cache_rebuild_by); + $this->Application->setCache('master:configs_parsed', serialize($cache), 0); + $this->Application->setCache('master:last_cache_rebuild', $cache_rebuild_by, 0); } else { - $this->Application->setDBCache('configs_parsed', serialize($cache)); - $this->Application->setDBCache('last_cache_rebuild', $cache_rebuild_by); + $this->Application->setDBCache('configs_parsed', serialize($cache), 0); + $this->Application->setDBCache('last_cache_rebuild', $cache_rebuild_by, 0); } } @@ -510,31 +520,31 @@ } /** - * Stores new $value in cache with $key name + * Stores new $value in cache with $name name. * - * @param int $key key name to add to cache - * @param mixed $value value of cached record - * @param int $expiration when value expires (0 - doesn't expire) - * @return bool - * @access public + * @param string $name Key name to add to cache. + * @param mixed $value Value of cached record. + * @param integer|null $expiration When value expires (0 - doesn't expire). + * + * @return boolean */ - public function setCache($key, $value, $expiration = 0) + public function setCache($name, $value, $expiration = null) { - return $this->cacheHandler->setCache($key, $value, $expiration); + return $this->cacheHandler->setCache($name, $value, $expiration); } /** * Stores new $value in cache with $key name (only if not there already) * - * @param int $key key name to add to cache - * @param mixed $value value of cached record - * @param int $expiration when value expires (0 - doesn't expire) - * @return bool - * @access public + * @param string $name Key name to add to cache. + * @param mixed $value Value of cached record. + * @param integer|null $expiration When value expires (0 - doesn't expire). + * + * @return boolean */ - public function addCache($key, $value, $expiration = 0) + public function addCache($name, $value, $expiration = null) { - return $this->cacheHandler->addCache($key, $value, $expiration); + return $this->cacheHandler->addCache($name, $value, $expiration); } /** @@ -670,15 +680,15 @@ } /** - * Sets value to database cache + * Sets value to database cache. * - * @param string $name - * @param mixed $value - * @param int|bool $expiration + * @param string $name Key name to add to cache. + * @param mixed $value Value of cached record. + * @param integer|null $expiration When value expires (0 - doesn't expire). + * * @return void - * @access public */ - public function setDBCache($name, $value, $expiration = false) + public function setDBCache($name, $value, $expiration = null) { $this->cacheHandler->storeStatistics($name, 'WU'); @@ -687,18 +697,21 @@ } /** - * Sets value to database cache + * Sets value to database cache. * - * @param string $name - * @param mixed $value - * @param int|bool $expiration - * @param string $insert_type - * @return bool - * @access protected + * @param string $name Key name to add to cache. + * @param mixed $value Value of cached record. + * @param integer|null $expiration When value expires (0 - doesn't expire). + * @param string $insert_type Insert type. + * + * @return boolean */ - protected function _setDBCache($name, $value, $expiration = false, $insert_type = 'REPLACE') + protected function _setDBCache($name, $value, $expiration = null, $insert_type = 'REPLACE') { - if ( (int)$expiration <= 0 ) { + if ( $expiration === null ) { + $expiration = $this->maxCacheDuration; + } + elseif ( (int)$expiration <= 0 ) { $expiration = -1; }