You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
2.0 KiB

2 years ago
  1. # Filesystem PSR-6 Cache pool
  2. [![Gitter](https://badges.gitter.im/php-cache/cache.svg)](https://gitter.im/php-cache/cache?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
  3. [![Latest Stable Version](https://poser.pugx.org/cache/filesystem-adapter/v/stable)](https://packagist.org/packages/cache/filesystem-adapter)
  4. [![codecov.io](https://codecov.io/github/php-cache/filesystem-adapter/coverage.svg?branch=master)](https://codecov.io/github/php-cache/filesystem-adapter?branch=master)
  5. [![Total Downloads](https://poser.pugx.org/cache/filesystem-adapter/downloads)](https://packagist.org/packages/cache/filesystem-adapter)
  6. [![Monthly Downloads](https://poser.pugx.org/cache/filesystem-adapter/d/monthly.png)](https://packagist.org/packages/cache/filesystem-adapter)
  7. [![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE)
  8. This is a PSR-6 cache implementation using Filesystem. It is a part of the PHP Cache organisation. To read about
  9. features like tagging and hierarchy support please read the shared documentation at [www.php-cache.com](http://www.php-cache.com).
  10. This implementation is using the excellent [Flysystem](http://flysystem.thephpleague.com/).
  11. ### Install
  12. ```bash
  13. composer require cache/filesystem-adapter
  14. ```
  15. ### Use
  16. To create an instance of `FilesystemCachePool` you need to configure a `Filesystem` and its adapter.
  17. ```php
  18. use League\Flysystem\Adapter\Local;
  19. use League\Flysystem\Filesystem;
  20. use Cache\Adapter\Filesystem\FilesystemCachePool;
  21. $filesystemAdapter = new Local(__DIR__.'/');
  22. $filesystem = new Filesystem($filesystemAdapter);
  23. $pool = new FilesystemCachePool($filesystem);
  24. ```
  25. You can change the folder the cache pool will write to through the `setFolder` setter:
  26. ```php
  27. $pool = new FilesystemCachePool($filesystem);
  28. $pool->setFolder('path/to/cache');
  29. ```
  30. ### Contribute
  31. Contributions are very welcome! Send a pull request to the [main repository](https://github.com/php-cache/cache) or
  32. report any issues you find on the [issue tracker](http://issues.php-cache.com).