PHP code example of cache / filesystem-adapter

1. Go to this page and download the library: Download cache/filesystem-adapter library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

cache / filesystem-adapter example snippets


use Cache\Adapter\Filesystem\FilesystemCachePool;
use League\Flysystem\Filesystem;
use League\Flysystem\Local\LocalFilesystemAdapter;

$filesystem = new Filesystem(new LocalFilesystemAdapter(__DIR__.'/storage'));
$pool = new FilesystemCachePool($filesystem);

$pool = new FilesystemCachePool($filesystem, 'path/to/cache');

$pool->setFolder('tenant/cache');
$pool->setFilesystem($replacementFilesystem);

$folder = $pool->getFolder();
$filesystem = $pool->getFilesystem();

final class ShardedFilesystemCachePool extends FilesystemCachePool
{
    protected function getFilePath(string $key): string
    {
        $path = parent::getFilePath($key);

        return $this->getFolder().'/tenant/'.substr($path, strlen($this->getFolder()) + 1);
    }
}