PHP code example of xp-forge / redis

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

    

xp-forge / redis example snippets


use io\redis\RedisProtocol;

$protocol= new RedisProtocol('redis://localhost');
$protocol->command('SET', 'key', 'value');

$value= $protocol->command('GET', 'key');

use io\redis\RedisProtocol;

$protocol= new RedisProtocol('redis://localhost');
$protocol->command('SUBSCRIBE', 'messages');

while ($message= $protocol->receive()) {
  Console::writeLine('Received ', $message);
}