xp-forge / redis
Redis 协议
v1.1.0
2024-03-24 13:22 UTC
Requires
- php: >=7.0.0
- xp-forge/uri: ^2.0 | ^1.0
- xp-framework/core: ^12.0 | ^11.0 | ^10.0 | ^9.0 | ^8.0 | ^7.0
- xp-framework/networking: ^10.0 | ^9.0 | ^8.0 | ^7.0
Requires (Dev)
- xp-framework/test: ^2.0 | ^1.0
README
Redis 协议 实现。
示例
use io\redis\RedisProtocol; $protocol= new RedisProtocol('redis://localhost'); $protocol->command('SET', 'key', 'value'); $value= $protocol->command('GET', 'key');
默认端口为 6379,可以通过以下方式更改:redis://localhost:16379。要使用身份验证,请在连接字符串中传递用户名,例如 redis://secret@localhost。
发布/订阅
use io\redis\RedisProtocol; $protocol= new RedisProtocol('redis://localhost'); $protocol->command('SUBSCRIBE', 'messages'); while ($message= $protocol->receive()) { Console::writeLine('Received ', $message); }