This is a Redis adapter for Flysystem.
Composer is the best way, as with all of Flysystem!
composer require danhunsaker/flysystem-redis
The usual. Create a client instance, pass it to the adapter, and pass that to the filesystem:
use Predis\Client;
use League\Flysystem\Filesystem;
use Danhunsaker\Flysystem\Redis\RedisAdapter;
$redis = new Client();
$adapter = new RedisAdapter($redis);
$filesystem = new Filesystem($adapter);
If Predis's assumed defaults of 127.0.0.1
and 6379
for host and port (respectively) aren't sufficient, you can pass your own values, just as you normally would when setting up Predis elsewhere in your projects:
use Predis\Client;
use League\Flysystem\Filesystem;
use Danhunsaker\Flysystem\Redis\RedisAdapter;
$redis = new Client([
'scheme' => 'tcp',
'host' => '10.0.0.1',
'port' => 6379,
]);
$adapter = new RedisAdapter($redis);
$filesystem = new Filesystem($adapter);
See the Predis docs for more on how to set it up...
And head to GitHub for everything else.