php - CakePHP and APC


When I try to set up Apc cache for counter in CakePhp,

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

It displays the following error :

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

However, if I check phpinfo, it show the following :


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_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

How Can I properly set up and use Apc caching with CakePHP ?

Thanks a lot for your help !




Your cache config doesn't look quite right.

Can you try this:

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

Take a look at the documentation:

People are also looking for solutions to the problem: php - PHPStorm 7 REST Client allow self signed certificates


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.