May 14, 2021 Swoole
The Swoole-1.8.14 version adds a Server framework compatible with the Redis server-side protocol, which enables server programs that implement the Redis protocol based on this framework.
Swoole\Redis\Server
from
Swoole\Server
all methods provided by the parent class.
Redis\Server
set the
onReceive
Instance program:
Https://github.com/swoole/swoole-src/blob/master/examples/redis/server.php
redis-cli
redis-benchmark
Swoole-1.8.0
support
for asynchronous Redis clients, based on the
hiredis library implementation officially available by
redis. S
woole provides __call
__call
method to map the vast
majority of Redis instructions.
With the Redis client, thehiredis library needs to be installed.
After
hiredis
source code, execute
make -j
sudo make install
sudo ldconfig
Compilation swoole is to add
--enable-async-redis
configure
./configure --enable-async-redis
make clean
make -j
sudo make install
$redis = new Swoole\Redis;
$redis->connect('127.0.0.1', 6379, function ($redis, $result) {
$redis->set('test_key', 'value', function ($redis, $result) {
$redis->get('test_key', function ($redis, $result) {
var_dump($result);
});
});
});
$cli = new Swoole\Http\Client('127.0.0.1', 80);
$cli->setHeaders(array('User-Agent' => 'swoole-http-client'));
$cli->setCookies(array('test' => 'value'));
$cli->post('/dump.php', array("test" => 'abc'), function ($cli) {
var_dump($cli->body);
$cli->get('/index.php', function ($cli) {
var_dump($cli->cookies);
var_dump($cli->headers);
});
});