xp-forge/redis

Redis Protocol

v1.1.0 2024-03-24 13:22 UTC

This package is auto-updated.

Last update: 2024-11-05 11:29:23 UTC


README

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);
}