PHP code example of reactphp-x / redis-pool
1. Go to this page and download the library: Download reactphp-x/redis-pool library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
reactphp-x / redis-pool example snippets
eactphpX\Redis\Pool;
use function React\Async\await;
$pool = new Pool(
uri: getenv('REDIS_URL') ?: '127.0.0.1:6379',
minConnections: 2,
maxConnections: 10,
waitQueue: 100,
waitTimeout: 0,
);
// see https://github.com/clue/reactphp-redis?tab=readme-ov-file#quickstart-example
await($pool->set('greeting', 'Hello world'));
await($pool->append('greeting', '!'));
$pool->get('greeting')->then(function (string $greeting) {
// Hello world!
echo $greeting . PHP_EOL;
});
$pool->incr('invocation')->then(function (int $n) {
echo 'This is invocation #' . $n . PHP_EOL;
});