cytec / zend3-cache-predis
Redis adapter for Zend Framework 3 with tagging support
Installs: 2 237
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 3
Forks: 0
Open Issues: 0
Requires
- php: ^5.6 || ^7.0
- predis/predis: ^1.1
- zendframework/zend-cache: ^2.8
Requires (Dev)
- phpunit/phpunit: ^4.0 || ^5.0
- zendframework/zend-serializer: ^2.8
README
Redis adapter for Zend framework 3 with tagging support
Installation
composer require cytec/zend3-cache-predis
Configuration
Somewhere in your configuration (eg. config/autoload/global.php) add
... 'caches' => [ 'AppCache' => [ 'plugins' => ['serializer'], 'adapter' => [ 'name' => '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:' ] ], ], ], ] ...
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);