PHP code example of phpdot / redis

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

    

phpdot / redis example snippets


use PHPdot\Redis\Config\RedisConfig;
use PHPdot\Redis\RedisConnection;

$connection = new RedisConnection(new RedisConfig(
    host: '127.0.0.1',
    port: 6379,
    password: 'secret',
    database: 0,
));

$connection->connect();

// Reach the underlying ext-redis \Redis client for commands
$connection->getClient()->set('hello', 'world');
$connection->getClient()->get('hello'); // 'world'

$connection->close();

use PHPdot\Redis\RedisConnector;

$connector = new RedisConnector(new RedisConfig(host: '127.0.0.1'));
// hand $connector to a phpdot/pool Pool — connect() opens, isAlive() pings, close() tears down