This package provides a PSR-6 cache pool for Redis, RedisArray, and RedisCluster clients from PhpRedis.
Use the Predis adapter when your application uses Predis.
Install the package and enable the Redis extension:
composer require cache/redis-adapter:^3.0use Cache\Adapter\Redis\RedisCachePool;
$client = new Redis();
$client->connect('127.0.0.1', 6379);
$pool = new RedisCachePool($client);The pool also accepts RedisArray and RedisCluster clients:
$array = new RedisArray(['127.0.0.1:6379', '127.0.0.2:6379']);
$arrayPool = new RedisCachePool($array);
$cluster = new RedisCluster(null, [
'127.0.0.1:7000',
'127.0.0.1:7001',
'127.0.0.1:7002',
]);
$clusterPool = new RedisCachePool($cluster);Version 3 stores tag indexes as sorted sets under the reserved php-cache:tag: prefix. Each index expires with its longest-lived item and stays persistent while it contains a non-expiring item.
Each tagged item stores a generation snapshot. The sorted set stores the current generation marker with the item index.
After the last indexed item is removed, the generation marker remains for 60 seconds. This lets an immediate rewrite reuse the same generation before the new index member is added.
Version 2 uses Redis sets under tag! keys. Version 3 does not read those indexes.
Stop all workers, clear the Redis cache, and then deploy version 3. Follow the same sequence before a rollback.
RedisArray runs tag scripts on the current shard selected for each tag key. Its index, autorehash, and previous-ring fallbacks do not apply to tag indexes. Stop workers and clear the cache before changing the RedisArray ring.
Version 2 stores tag indexes as Redis sets. Older releases use Redis lists for the same keys.
Stop all workers, clear the Redis cache, and then deploy version 2. Follow the same sequence before a rollback.
Send pull requests to the main repository. Report issues on the GitHub issue tracker.