workerman / redis
Installs: 124 130
Dependents: 16
Suggesters: 1
Security: 0
Stars: 18
Watchers: 5
Forks: 7
Open Issues: 3
Requires
- php: >=7
- workerman/workerman: ^4.1.0||^5.0.0
README
Asynchronous redis client for PHP based on workerman.
Install
composer require workerman/redis
Usage
require_once __DIR__ . '/vendor/autoload.php'; use Workerman\Redis\Client; use Workerman\Worker; $worker = new Worker('http://0.0.0.0:6161'); $worker->onWorkerStart = function() { global $redis; $redis = new Client('redis://127.0.0.1:6379'); }; $worker->onMessage = function($connection, $data) { global $redis; $redis->set('key', 'hello world'); $redis->get('key', function ($result) use ($connection) { $connection->send($result); }); }; Worker::runAll();