29/12
2017
an async redis wrapper for phpredis
an async redis wrapper for phpredis, (*1)
PHP 5.4+ is required. phpredis extension is required., (*2)
Append dependency into composer.json, (*3)
... "require": { ... "shen2/easy-redis": "dev-master" } ...
<?php $config = array( 'host' => 'localhost', 'port' => 6379, 'persistent'=> false, 'database' => 0, 'profiler' => true, ); // Create a connection. $redisManager = new EasyRedis\Manager($config); // send request synchronously. $redisManager->send('set', ['a', 'abc']); echo $redisManager->send('get', ['a']) . "\n"; // send request asynchronously $redisManager->sendAsync('set', ['a', 'abc']); $redisManager->sendAsync('set', ['b', '123'])->then(function(){ echo "successed.\n"; });