PHP code example of chuxiangqaz / redis-client

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

    

chuxiangqaz / redis-client example snippets


$config = [
    // use php extensions config 'phpredis'
    'client' => 'predis',
    
    'default' => [
        'host'     => '127.0.0.1',
        'port'     => 6379,
        'database' =>  0,
        'password' =>  null,
    ],
];


$redisManager = new \CxRedis\RedisManager($config['client'], $config);
$redisClient = $redisManager->connection();

$redisClient->set('name', 'test');
echo $redisClient->get('name');

use CxRedis\RedisFacade;

$config = [
    'client' => 'predis',
    'default' => [
        'host'     => '127.0.0.1',
        'port'     => 6379,
        'database' =>  0,
        'password' =>  null,
    ],
];

$facade = new RedisFacade();
$facade->register($config);

RedisFacade::set('name', 'test');
echo RedisFacade::get('name');