webpatser / fledge-fiber-redis
Non-blocking Fiber-based Redis driver for Fledge/Laravel using amphp
Requires
- php: ^8.5
- amphp/redis: ^2.0
- illuminate/redis: ^13.0
- illuminate/support: ^13.0
Requires (Dev)
- mockery/mockery: ^1.6
- pestphp/pest: ^4.0
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:
- The command is sent over the socket
- The current Fiber suspends while waiting for the response
- Other Fibers progress (database queries, HTTP requests, etc.)
- 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