Upgrading to Laminas-cache v3

Hello,

I upgraded my laminas-cache to 3.1.2 (from 2.13.2) with laminas-cache-storage-adapter-filesystem.

In my /config/autoload/global.php I have this configuration:

'caches' => [
        'cache1' => [
            'adapter' => [
                'name'     =>'filesystem',
                'options'  => [
                    'ttl' => 10800,
                    'cacheDir' => 'data/cache/cache1',
                    'dir_level' => 0,
                    'readable' => false,
                    'writable' => false,
                ]
            ],
            'plugins' => [
                'exception_handler' => [
                    'throw_exceptions' => false
                ],
                'Serializer'
            ],
        ],
        'cache2' => [
            'adapter' => [
                'name'     =>'filesystem',
                'options'  => [
                    'ttl' => 0,
                    'cacheDir' => 'data/cache/cache2',
                    'dir_level' => 0,
                    'readable' => false,
                    'writable' => false,
                ]
            ],
            'plugins' => [
                'exception_handler' => [
                    'throw_exceptions' => false
                ],
                'Serializer'
            ],
        ],
    ],

But I have this error:
Service with name "cache1" could not be created. Reason: Configuration must contain a "adapter" key.

There is the adapter key in cache1, what it is the problem please?

I anwser to mysleft, it can help others, here is the correct configuration:

'caches' => [
        'cache1' => [
            'adapter' => 'filesystem',
            'options' => [
                'ttl' => 10800,
                'cacheDir' => 'data/cache/cache1',
                'dir_level' => 0,
                'readable' => false,
                'writable' => false,
            ],
            'plugins' => [
                [
                    'name' => 'exception_handler',
                    'options' => [
                        'throw_exceptions' => false,
                    ],
                ],
            ],
        ],
        'cache2' => [
            'adapter' => 'filesystem',
            'options' => [
                'ttl' => 0,
                'cacheDir' => 'data/cache/cache2',
                'dir_level' => 0,
                'readable' => false,
                'writable' => false,
            ],
            'plugins' => [
                [
                    'name' => 'exception_handler',
                    'options' => [
                        'throw_exceptions' => false,
                    ],
                ],
            ],
        ],
    ],

See also in the documentation: Adapters - laminas-cache - Laminas Docs

1 Like