ZF-12109: Zend Cache - Custom backend via config .ini file is not possible.

Issue Type: Bug Created: 2012-03-21T08:53:00.000+0000 Last Updated: 2012-03-21T08:53:00.000+0000 Status: Open Fix version(s): Reporter: Ilan Rivers (ilanr) Assignee: Alexander Veremyev (alexander) Tags: - Zend_Cache

Related issues: Attachments:


It is currently not possible to use a custom class when setting cache options via the config .ini file.

A normal config setting would look like this : = "Apc"

To use a custom class one needs to set the option "customBackendNaming" so the setting would then look like this : = "My_Cache_Backend_Apc" resources.cachemanager.default.backend.customBackendNaming = true

The issue occurs in the Zend_Cache_Manager class. The problem is that the customBackendNaming option is never passed to the Zend_Cache::factory method. This is because this class assumes the only options from the config .ini file will be a key called "name" and a key called "options" and other settings are filtered out in the _mergeOptions method.

Below I have posted the Zend_Cache_Manager::_mergeOptions method with a proposed fix.

/** * Simple method to merge two configuration arrays * * @param array $current * @param array $options * @return array */ protected function _mergeOptions(array $current, array $options) { if (isset($options['frontend']['name'])) { $current['frontend']['name'] = $options['frontend']['name']; }

    if (isset($options['backend']['name'])) {
        $current['backend']['name'] = $options['backend']['name'];

    if (isset($options['frontend']['options'])) {
        foreach ($options['frontend']['options'] as $key=>$value) {
            $current['frontend']['options'][$key] = $value;
    if (isset($options['backend']['options'])) {
        foreach ($options['backend']['options'] as $key=>$value) {
            $current['backend']['options'][$key] = $value;

    if (isset($options['frontend']['customFrontendNaming'])) {
        $current['frontend']['customFrontendNaming'] = $options['frontend']['customFrontendNaming'];

    if (isset($options['backend']['customBackendNaming'])) {
        $current['backend']['customBackendNaming'] = $options['backend']['customBackendNaming'];
    // END EDIT

    return $current;


No comments to display

Have you found an issue?

See the Overview section for more details.


© 2006-2018 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.