PHP code example of cytec / laminas-cache-predis

1. Go to this page and download the library: Download cytec/laminas-cache-predis library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

cytec / laminas-cache-predis example snippets


...
'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']
        ],
    ]
],
...



return [
    ...{your other modules}...
    'Cytec\Cache\Storage\Adapter\Predis',
];

$client = new Predis\Client($predis_client_connections, $predis_client_options);

$cache = $this->getServiceManager()->get('AppCache');
$cache->setItem($key, $value);