Search by

gecole / cache-redis

ecoleplus

Redis cache store for the Gecole framework, added as an optional package so the core stays dependency-free.

Package info

gitlab.com/gecole/cache-redis

Issues

pkg:composer/gecole/cache-redis

Statistics

Installs: 2

Dependents: 0

Suggesters: 1

Stars: 0

dev-main 2026-09-21 14:26 UTC

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