gecole / cache-redis
Redis cache store for the Gecole framework, added as an optional package so the core stays dependency-free.
Requires
- php: >=8.3
- gecole/framework: *
Requires (Dev)
None
Suggests
- ext-redis: Use the native Redis extension as the client
- predis/predis: Use the pure-PHP Predis client instead
Provides
None
Conflicts
None
Replaces
None
This package is not auto-updated.
Last update: 2026-09-22 12:47:40 UTC
README
An optional Redis cache store for the Gecole framework. The framework core stays dependency-free; install this package when you want a Redis backend.
composer require gecole/cache-redis
composer require predis/predis # or install the native php-redis extension
Enable
Add the service provider and switch the cache driver to redis:
// config/app.php
'providers' => [ /* …, */ \Gecole\Cache\Redis\CacheServiceProvider::class ],
'cache' => [
'driver' => 'redis',
'prefix' => '',
'ttl' => 3600,
'redis' => [
'host' => env('REDIS_HOST', '127.0.0.1'),
'port' => (int) env('REDIS_PORT', 6379),
'password' => (string) env('REDIS_PASSWORD', ''),
'database' => (int) env('REDIS_DB', 0),
],
],
If you prefer not to add a provider, register the driver yourself:
$app->cacheManager()->addDriver('redis', fn (array $o) => \Gecole\Cache\Redis\RedisStore::fromConfig($o));
Values are PHP-serialized so arrays and objects round-trip exactly; null/0
TTL means no expiry. Increments (Repository::increment) are implemented as
read-modify-write to stay consistent with the stored values.
Client
RedisStore::fromConfig() picks Predis\Client first (pure PHP) and falls back
to the native \Redis extension. Pass an explicit client to the constructor if
you need to reuse a connection.
Tests
php tests/run.php # exercises the store against an in-memory fake client