From 60e6bbcc135fa21655733ff41912e5d73ba8d264 Mon Sep 17 00:00:00 2001 From: knut <> Date: Mon, 11 Jun 2007 16:02:28 +0000 Subject: fixed #646 --- framework/Caching/TAPCCache.php | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) (limited to 'framework/Caching') diff --git a/framework/Caching/TAPCCache.php b/framework/Caching/TAPCCache.php index 969de4a4..253507b6 100644 --- a/framework/Caching/TAPCCache.php +++ b/framework/Caching/TAPCCache.php @@ -40,6 +40,7 @@ * * * @author Alban Hanry + * @author Knut Urdalen * @version $Id$ * @package System.Caching * @since 3.0b @@ -54,12 +55,16 @@ class TAPCCache extends TCache */ public function init($config) { - if(substr(php_sapi_name(), 0, 3) !== 'cli') //APC is usually disabled in CLI mode. - { - if(!extension_loaded('apc')) - throw new TConfigurationException('apccache_extension_required'); - parent::init($config); - } + if(!extension_loaded('apc')) + throw new TConfigurationException('apccache_extension_required'); + + if(ini_get('apc.enabled') == false) + throw new TConfigurationException('apccache_extension_not_enabled'); + + if(substr(php_sapi_name(), 0, 3) === 'cli' and ini_get('apc.enable_cli') == false) + throw new TConfigurationException('apccache_extension_not_enabled_cli'); + + parent::init($config); } /** @@ -98,7 +103,11 @@ class TAPCCache extends TCache */ protected function addValue($key,$value,$expire) { - throw new TNotSupportedException('apccache_add_unsupported'); + if(function_exists('apc_add')) { + return apc_add($key,$value,$expire); + } else { + throw new TNotSupportedException('apccache_add_unsupported'); + } } /** -- cgit v1.2.3