webpatser/fledge-fiber-redis

Non-blocking Fiber-based Redis driver for Fledge/Laravel using amphp

Maintainers

Package info

github.com/webpatser/fledge-fiber-redis

pkg:composer/webpatser/fledge-fiber-redis

Statistics

Installs: 4

Dependents: 0

Suggesters: 1

Stars: 0

Open Issues: 0

v13.3.0.0 2026-04-06 14:16 UTC

This package is auto-updated.

Last update: 2026-04-06 14:17:33 UTC


README

Non-blocking, Fiber-based Redis driver for Fledge and Laravel 13 using amphp/redis.

Drop-in replacement for the standard phpredis/predis drivers that suspends PHP Fibers during I/O instead of blocking. This means Redis operations (cache, session, queue, locks) can run concurrently with other Fiber-based I/O like database queries and HTTP requests.

Requirements

  • PHP 8.5+
  • Fledge / Laravel 13 (with getPrefix() support on Redis connections)
  • amphp/redis ^2.0 (included)

Installation

composer require webpatser/fledge-fiber-redis

The service provider is auto-discovered.

Configuration

Set the Redis client in your .env:

REDIS_CLIENT=amphp

Or in config/database.php:

'redis' => [
    'client' => env('REDIS_CLIENT', 'amphp'),
    // ... rest stays the same
],

All existing Redis config (host, port, password, database, prefix) works unchanged.

How It Works

The amphp Redis driver uses the Revolt event loop for non-blocking socket I/O. When a Redis command is executed:

  1. The command is sent over the socket
  2. The current Fiber suspends while waiting for the response
  3. Other Fibers progress (database queries, HTTP requests, etc.)
  4. When the response arrives, the Fiber resumes

All Laravel Redis features work: caching, sessions, queues, locks, pub/sub, pipelines, transactions, Lua scripts.

Pipelines

The amphp driver automatically batches commands via the event loop. For explicit concurrent execution:

$results = Redis::pipeline(function ($pipe) {
    $pipe->set('key1', 'value1');
    $pipe->set('key2', 'value2');
    $pipe->get('key1');
});

Limitations

  • Redis Cluster is not supported by amphp/redis. Use phpredis or predis for cluster connections.

Testing

composer test

License

MIT