Skip to content

xp-forge/redis

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Redis protocol

Build status on GitHub XP Framework Module BSD Licence Requires PHP 7.0+ Supports PHP 8.0+ Latest Stable Version

Redis protocol implementation.

Example

use io\redis\RedisProtocol;

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

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

The port defaults to 6379 and can be changed by adding it as follows: redis://localhost:16379. To use authentication, pass it as username in the connection string, e.g. redis://secret@localhost.

Pub/Sub

use io\redis\RedisProtocol;

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

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