buzzingpixel/redis-psr-cache-implementation

An implementation of the PSR Cache interface for Redis

Maintainers

Package info

github.com/buzzingpixel/redis-psr-cache-implementation

pkg:composer/buzzingpixel/redis-psr-cache-implementation

Statistics

Installs: 3

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

1.0.0 2022-01-04 23:38 UTC

This package is auto-updated.

Last update: 2026-03-05 08:33:15 UTC


README

Usage

// Create a Redis instance
$redis = new \Redis();
$redis->connect(getenv('REDIS_HOST'));

// Create the RedisCacheItemPool and send it the redis instance
$cacheItemPool = new \BuzzingPixel\RedisCache\RedisCacheItemPool($redis);

And here's an example of configuring the BuzzingPixel Container to use the RedisCacheItemPool by default when auto-wiring the PSR CacheItemPoolInterface (other containers can be configured similarly).

$container = new \BuzzingPixel\Container\Container(
    bindings: [
        \Psr\Cache\CacheItemPoolInterface::class => \BuzzingPixel\RedisCache\RedisCacheItemPool::class,
        \Redis::class => static function (): \Redis {
            $redis = new \Redis();
            $redis->connect(getenv('REDIS_HOST'));
            return $redis;
        }
    ]
);