0

当我尝试在 CakePhp 中为计数器设置 Apc 缓存时,

Cache::config('counters', array(
    'engine' => 'Apc',
    'duration' => 3600,
    'prefix' => Inflector::slug(APP_DIR) . 'counters_',
));

它显示以下错误:

Fatal error: Uncaught exception 'CacheException' with message 'Cache engine counters is
not properly configured.' in /home/mysite/www/lib/Cake/Cache/Cache.php:181 
Stack trace: #0 /home/mysite/www/lib/Cake/Cache/Cache.php(151):
 Cache::_buildEngine('counters') #1 /home/mysite/www/app/Config/core.php(409):
 Cache::config('counters', Array) #2 /home/mysite/www/lib/Cake/Core/Configure.php(72):
 include('/home/mysite/w...') #3 /home/mysite/www/lib/Cake/bootstrap.php(177):
 Configure::bootstrap(true) #4 /home/mysite/www/app/webroot/index.php(91):
 include('/home/mysite/w...') #5 {main} thrown in /home/mysite/www/lib/Cake/Cache/Cache.php on line 181

但是,如果我检查 phpinfo,它会显示以下内容:

apc

APC Support enabled
Version 3.0.16
MMAP Support    Enabled
MMAP File Mask  no value
Locking type    pthread mutex Locks
Revision    $Revision: 3.154 $
Build Date  Oct 29 2013 17:02:31

Directive   Local Value Master Value
apc.cache_by_default    On  On
apc.coredump_unmap  Off Off
apc.enable_cli  Off Off
apc.enabled On  On
apc.file_update_protection  2   2
apc.filters no value    no value
apc.gc_ttl  3600    3600
apc.include_once_override   Off Off
apc.localcache  Off Off
apc.localcache.size 512 512
apc.max_file_size   1M  1M
apc.mmap_file_mask  no value    no value
apc.num_files_hint  1000    1000
apc.report_autofilter   Off Off
apc.rfc1867 Off Off
apc.rfc1867_freq    0   0
apc.rfc1867_name    APC_UPLOAD_PROGRESS APC_UPLOAD_PROGRESS
apc.rfc1867_prefix  upload_ upload_
apc.shm_segments    1   1
apc.shm_size    30  30
apc.slam_defense    0   0
apc.stat    On  On
apc.stat_ctime  Off Off
apc.ttl 0   0
apc.user_entries_hint   4096    4096
apc.user_ttl    0   0
apc.write_lock  On  On

如何正确设置和使用 CakePHP 的 Apc 缓存?

非常感谢你的帮助 !

4

1 回答 1

-1

您的缓存配置看起来不太正确。

你可以试试这个:

Cache::config('counters', array(
    'engine' => 'Apc',
    'duration' => 3600,
    'prefix' => 'apc_',
));

看看文档:http ://book.cakephp.org/2.0/en/core-libraries/caching.html

于 2013-11-06T15:15:33.487 回答