PHP code example of e96 / yii2-redis

1. Go to this page and download the library: Download e96/yii2-redis 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/ */

    

e96 / yii2-redis example snippets


function fill($keys)
{
    foreach ($keys as $key) {
        yield $key;
        yield 0;
    }
}

$keys = $redis->executeCommand('LRANGE', ['model', 0, -1]);
$keys = iterator_to_array(fill($keys));
$keys = array_unshift($keys, 'model')

$redis->executeCommand('DEL', 'model')
$redis->executeCommand('HMSET', $keys)

return [
    //....
    'components' => [
        'redis' => [
            'class' => 'yii\redis\Connection',
            'hostname' => 'localhost',
            'port' => 6379,
            'database' => 0,
        ],
    ]
];