Search code examples
phpcakephpcachingapccakephp-3.x

How to properly configure the Apc cache engine?


I'm facing problems when trying to configure Cache in Cakephp 3. My config is as follows:

Cache => [
    'default' => [
        'className' => 'Apc',
        'path' => CACHE,
    ],
    '_cake_core_' => [
        'className' => 'Apc',
        'prefix' => 'mandealR_cake_core_',
        'path' => CACHE . 'persistent/',
        'serialize' => true,
        'duration' => '+2 minutes',
    ],
    '_cake_model_' => [
        'className' => 'Apc', 
        'prefix' => 'mandealR_cake_model_',
        'path' => CACHE . 'models/',
        'serialize' => true, 
        'duration' => '+2 minutes', 
    ],
    'apc' => [
        'engine' => 'Apc' 
    ]
]

I can get

Cache engine Cake\Cache\Engine\ApcEngine is not properly configured.

Can someone help me finding the right config ?


Solution

  • APCu as of CakePHP 3.2

    As of CakePHP 3.2, the Apc cache engine doesn't actually use the APC extension anymore (which has been definitely discontinued ever since PHP 5.5 shipped with bundled opcode caching), but the APCu extension.

    http://php.net/manual/en/book.apcu.php

    The migration guide as well as the caching docs seem to lack that information.

    Extension not loaded

    The error you are receiving generally occours when the extension is not loaded - being it APC or APCu (!extension_loaded('apc') / !extension_loaded('apcu')). So make sure that you've configured your PHP installation properly, and that the required extension is installed/loaded.

    ps.

    the Apc engine doesn't support a path option.