https://github.com/xp-forge/redis
Redis Protocol
https://github.com/xp-forge/redis
redis resp xp-framework
Last synced: 4 months ago
JSON representation
Redis Protocol
- Host: GitHub
- URL: https://github.com/xp-forge/redis
- Owner: xp-forge
- Created: 2019-08-24T15:52:21.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2025-01-19T09:46:04.000Z (over 1 year ago)
- Last Synced: 2025-08-13T04:17:44.865Z (10 months ago)
- Topics: redis, resp, xp-framework
- Language: PHP
- Size: 25.4 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: ChangeLog.md
Awesome Lists containing this project
README
Redis protocol
==============
[](https://github.com/xp-forge/redis/actions)
[](https://github.com/xp-framework/core)
[](https://github.com/xp-framework/core/blob/master/LICENCE.md)
[](http://php.net/)
[](http://php.net/)
[](https://packagist.org/packages/xp-forge/redis)
[Redis protocol](https://redis.io/topics/protocol) implementation.
Example
-------
```php
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
-------
```php
use io\redis\RedisProtocol;
$protocol= new RedisProtocol('redis://localhost');
$protocol->command('SUBSCRIBE', 'messages');
while ($message= $protocol->receive()) {
Console::writeLine('Received ', $message);
}
```