reactphp-x/redis-pool

v2.0.0 2025-02-04 09:03 UTC

This package is auto-updated.

Last update: 2025-02-04 09:04:08 UTC


README

install

composer require reactphp-x/redis-pool -vvv

Usage

<?php

require __DIR__ . '/../vendor/autoload.php';

use ReactphpX\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;
});