Download src/Shared/Infrastructure/Providers/CacheServiceProvider.php from pnacorp/AIKEEDO: direct link, hf CLI and curl.
- Browser
- Download file 1.65 kB
-
https://huggingface.co/pnacorp/AIKEEDO/resolve/main/src/Shared/Infrastructure/Providers/CacheServiceProvider.php
- Command line
-
hf download hf://pnacorp/AIKEEDO/src/Shared/Infrastructure/Providers/CacheServiceProvider.php
-
curl -L -o CacheServiceProvider.php https://huggingface.co/pnacorp/AIKEEDO/resolve/main/src/Shared/Infrastructure/Providers/CacheServiceProvider.php
1.65 kB
| declare(strict_types=1); | |
| namespace Shared\Infrastructure\Providers; | |
| use Application; | |
| use Easy\Container\Attributes\Inject; | |
| use Psr\Cache\CacheItemPoolInterface; | |
| use Psr\SimpleCache\CacheInterface; | |
| use Shared\Infrastructure\ServiceProviderInterface; | |
| use Symfony\Component\Cache\Adapter\FilesystemAdapter; | |
| use Symfony\Component\Cache\Psr16Cache; | |
| class CacheServiceProvider implements ServiceProviderInterface | |
| { | |
| /** | |
| * @param string $cacheDir | |
| * @return void | |
| */ | |
| public function __construct( | |
| #[Inject('config.dirs.cache')] | |
| private string $cacheDir | |
| ) { | |
| } | |
| /** | |
| * @inheritDoc | |
| */ | |
| public function register(Application $app): void | |
| { | |
| $adapter = new FilesystemAdapter(directory: $this->cacheDir); | |
| $app | |
| /** | |
| * FilesystemAdapter is a concrete implementation of | |
| * CacheItemPoolInterface. All of the its constructor arguments are | |
| * optional. Default cache location is system's temp directory. | |
| */ | |
| ->set(CacheItemPoolInterface::class, $adapter) | |
| /** | |
| * Psr16Cache is a concrete implementation of CacheInterface. It | |
| * wraps a PSR-6 cache pool and provides a PSR-16 implementation | |
| * that can be used to store and retrieve values from the cache. | |
| * | |
| * Psr16Cache contructor requires a PSR-6 cache pool as its only | |
| * argument. We are using FilesystemAdapter as our PSR-6 cache pool | |
| * implementation (defined above). | |
| */ | |
| ->set(CacheInterface::class, Psr16Cache::class); | |
| } | |
| } | |