Laminas Cache in MVC - Issue with ObjectCache


I have this in my configs/autoload/caches.local.php

return array(
    'caches' => array(
        'Cache\Persistent' => array(
            'adapter' => 'Laminas\Cache\Storage\Adapter\Filesystem',
            'maxTtl' => 1,
            'options' => [
                'cache_dir' => realpath(__DIR__ . '/../../data/cache/'),
                'dir_permission' => 0755,
                'file_permission' => 0666,
                'dir_level' => 1
            'plugins' => [
                'exception_handler' => [
                    'throw_exceptions' => true,

Later in my Module.php I am doing this

use Laminas\Cache\Pattern\ObjectCache;
use Laminas\Cache\Pattern\PatternOptions;
// in public function getServiceConfig()
'SampleTable' => function ($sm) {
					$dbAdapter = $sm->get('Laminas\Db\Adapter\Adapter');
					$tableObj = new SampleTable($dbAdapter);
					$storage = $sm->get('Cache\Persistent');
					$table = new ObjectCache(
						new PatternOptions([
							'object' => $tableObj,
							'object_key' => 'somekey'
					return $table;

I am getting this when I run the application:

An error occurred
An error occurred during execution; please try again later.
No Exception available

There is no stacktrace or any additional info on what is going on.

Please help me identify what I missed

Looking at your code style it is giving me an impression that this code is from ZF2 days. If I’m not wrong, the style of declaring a service via the Lamda function has been removed or discouraged. You’ve to declare your service via invoking or via a Factory method. Also, when a function is defined within a class it is called a method. Please, don’t hate me for this correction. You can correct me on Lamda function. Thanks!

Please have a look here to declare a service via a factory method.