cache / redis-adapter
A PSR-6 cache implementation using Redis (PhpRedis). This implementation supports tags
Requires
- php: >=7.4
- cache/adapter-common: ^1.0
- cache/hierarchical-cache: ^1.0
- psr/cache: ^1.0 || ^2.0
- psr/simple-cache: ^1.0
Requires (Dev)
- cache/integration-tests: ^0.17
- phpunit/phpunit: ^7.5.20 || ^9.5.10
Suggests
- ext-redis: The extension required to use this pool.
Provides
README
This is a PSR-6 cache implementation using Redis. It is a part of the PHP Cache organisation. To read about features like tagging and hierarchy support please read the shared documentation at www.php-cache.com.
This implementation is using PhpRedis. If you want an adapter with Predis you should look at our Predis adapter.
Install
composer require cache/redis-adapter
Use
To create an instance of RedisCachePool
you need to configure a \Redis
, \RedisArray
or \RedisCluster
client.
\Redis
$client = new \Redis(); $client->connect('127.0.0.1', 6379); $pool = new RedisCachePool($client);
\RedisArray
$client = new \RedisArray(['127.0.0.1:6379', '127.0.0.2:6379']); $pool = new RedisCachePool($client);
\RedisCluster
$client = new \RedisCluster(null, ['127.0.0.1:7000', '127.0.0.2:7001', '127.0.0.2:7002',]); $pool = new RedisCachePool($client);
See PhpRedis for more connection options
Contribute
Contributions are very welcome! Send a pull request to the main repository or report any issues you find on the issue tracker.