ApcCache和Memcache的Cakephp缓存配置

时间:2014-04-12 11:04:44

标签: cakephp caching memcached apc

我正在使用Cakephp 2.4.6,我希望在我的应用程序中使用缓存。 在我的Bootstrap.php中我找到了

                  Cache::config('default', array('engine' => 'File'));

在我的core.php中找到了

             Cache::config('_cake_core_', array(
                                      'engine' => $engine,
                                      'prefix' => $prefix . 'cake_core_',
                                      'path' => CACHE . 'persistent' . DS,
                                      'serialize' => ($engine === 'File'),
                                      'duration' => $duration
                                   ));

为模型和数据源缓存配置缓存。此缓存配置   用于存储模式描述和连接中的表列表。

                      Cache::config('_cake_model_', array(
                                    'engine' => $engine,
                                    'prefix' => $prefix . 'cake_model_',
                                    'path' => CACHE . 'models' . DS,
                                    'serialize' => ($engine === 'File'),
                                    'duration' => $duration
                                    ));

阅读文件Cakephp Caching¶后 我试图在Core.php中配置Apc Cach

                      Cache::config('default', array(
                                         'engine' => 'Apc',
                                       'duration'=> 9000,
                                           'probability'=> 100,
                                      'prefix' => Inflector::slug(APP_DIR) . '_',
                                     ));

显示错误

  Fatal error: Uncaught exception 'CacheException' with message 
       'Cache engine default is not properly configured.' in        C:\xampp\htdocs\go4add\lib\Cake\Cache\Cache.php:181 Stack trace: #0 

然后我尝试在bootstrap.php中配置,效果相同。 请帮帮我..我很困惑..

在cakephp中是否需要安装Apc Cache和memcache? 如果需要,请告诉我如何安装Apc i nCakeph

1 个答案:

答案 0 :(得分:1)

不要碰任何东西。只需将第352行的core.php上的$engine = 'File';更改为$engine = 'Apc';即可。不要忘记安装Apc。