cytec / laminas-cache-predis
Redis adapter for Laminas Framework 3 with tagging support
Installs: 37 306
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 4
Forks: 0
Open Issues: 0
Requires
- php: >=7.4
- laminas/laminas-cache: ^3.1
- predis/predis: ^1.1
Requires (Dev)
- laminas/laminas-config-aggregator: ^1.5
- laminas/laminas-serializer: ^2.12
- phpunit/phpunit: ^9.5
Provides
README
Redis adapter for Laminas framework with tagging support
Installation
composer require cytec/laminas-cache-predis
Configuration
Somewhere in your configuration (eg. config/autoload/global.php) add
... 'caches' => [ 'AppCache' => [ 'adapter' => 'Cytec\Cache\Storage\Adapter\Predis', 'options' => [ 'ttl' => 600, 'predis_client_connections' => [ 'host' => '127.0.0.1', 'port' => 6379, ], 'predis_client_options' => [ 'profile' => '2.4', 'prefix' => 'ns:' ] ], 'plugins' => [ ['name' => 'serializer'] ], ] ], ...
Since laminas-cache v3 storage adapters need to be registered as modules:
modules.config.php
:
<?php return [ ...{your other modules}... 'Cytec\Cache\Storage\Adapter\Predis', ];
The predis_client_connections
option is passed directly as the first argument when creating the Predis client and
predis_client_options
as the second parameter:
$client = new Predis\Client($predis_client_connections, $predis_client_options);
For more information check out Predis documentation on Connection Parameters and Client Options
And then you can get the cache via the service manager:
$cache = $this->getServiceManager()->get('AppCache'); $cache->setItem($key, $value);