I have installed php redis in my local system and have added the redis adapter via the composer command: composer require laminas/laminas-cache-storage-adapter-redis
I tried following this documentation: Adapters - laminas-cache - Laminas Docs
I am having trouble setting up the service and the factory files for the same
So far I have defined the options in a config file ‘redis.local.php’:
return [
'redis-cache' => [
'adapter' => [
'name' => 'redis',
'options' => [
'ttl' => 3600,
'server' => [
'host' => '127.0.0.1',
'port' => 6379,
],
],
],
'plugins' => [
[
'name' => 'exception_handler',
'options' => [
'throw_exceptions' => true,
],
],
],
]
];
and tried to add the options via the factory:
class RedisCacheServiceFactory implements FactoryInterface
{
public function __invoke(ContainerInterface $container, $requestedName, ?array $options = null): RedisCacheService
{
$config = $container->get('config');
return new RedisCacheService($config['redis-cache']);
}
}
and then try to typecast it as a StorageInterFace object (might be doing something wrong here):
class RedisCacheService
{
public function __construct(private StorageInterface $cacheStorage)
{
}
}
Please note: I am new to laminas, I also see an implementation where redis cache is coupled with doctrine.