-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from php-cache/updates
Updated to reflect changed in adapter common an tagging
- Loading branch information
Showing
7 changed files
with
99 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,28 @@ | ||
# Filesystem PSR-6 adapter using Flysystem | ||
[![Build Status](https://travis-ci.org/php-cache/filesystem-adapter.svg?branch=master)](https://travis-ci.org/php-cache/filesystem-adapter) [![codecov.io](https://codecov.io/github/php-cache/filesystem-adapter/coverage.svg?branch=master)](https://codecov.io/github/php-cache/filesystem-adapter?branch=master) | ||
# Filesystem PSR-6 Cache pool | ||
[![Latest Stable Version](https://poser.pugx.org/cache/filesystem-adapter/v/stable)](https://packagist.org/packages/cache/filesystem-adapter) [![codecov.io](https://codecov.io/github/php-cache/filesystem-adapter/coverage.svg?branch=master)](https://codecov.io/github/php-cache/filesystem-adapter?branch=master) [![Build Status](https://travis-ci.org/php-cache/filesystem-adapter.svg?branch=master)](https://travis-ci.org/php-cache/filesystem-adapter) [![Total Downloads](https://poser.pugx.org/cache/filesystem-adapter/downloads)](https://packagist.org/packages/cache/filesystem-adapter) [![Monthly Downloads](https://poser.pugx.org/cache/filesystem-adapter/d/monthly.png)](https://packagist.org/packages/cache/filesystem-adapter) [![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE) | ||
|
||
This is a implementation for the PSR-6 for a filesystem cache. This implementation supports tags. This adapter | ||
requires [Flysystem](http://flysystem.thephpleague.com/). | ||
This is a PSR-6 cache implementation for Filesystem. 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](http://www.php-cache.com). | ||
|
||
| Feature | Supported | | ||
| ------- | --------- | | ||
| Flush everything | Yes | ||
| Expiration time | Yes | ||
| Support for tags | Yes | ||
This implementation is using the excellent [Flysystem](http://flysystem.thephpleague.com/). | ||
|
||
### Install | ||
|
||
```bash | ||
composer require cache/filesystem-adapter | ||
``` | ||
|
||
### Configure | ||
|
||
To create an instance of `FilesystemCachePool` you need to configure a `Filesystem` and its adapter. | ||
|
||
```php | ||
use League\Flysystem\Adapter\Local; | ||
use League\Flysystem\Filesystem; | ||
use Cache\Adapter\Filesystem\FilesystemCachePool; | ||
|
||
$filesystemAdapter = new Local(__DIR__.'/'); | ||
$filesystem = new Filesystem($filesystemAdapter); | ||
|
||
$pool = new FilesystemCachePool($filesystem); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of php-cache\filesystem-adapter package. | ||
* | ||
* (c) 2015-2015 Aaron Scherer <aequasi@gmail.com>, Tobias Nyholm <tobias.nyholm@gmail.com> | ||
* | ||
* This source file is subject to the MIT license that is bundled | ||
* with this source code in the file LICENSE. | ||
*/ | ||
|
||
namespace Cache\Adapter\Filesystem\Tests; | ||
|
||
use Cache\Adapter\Filesystem\FilesystemCachePool; | ||
use League\Flysystem\Adapter\Local; | ||
use League\Flysystem\Filesystem; | ||
|
||
trait CreatePoolTrait | ||
{ | ||
/** | ||
* @type Filesystem | ||
*/ | ||
private $filesystem; | ||
|
||
public function createCachePool() | ||
{ | ||
return new FilesystemCachePool($this->getFilesystem()); | ||
} | ||
|
||
private function getFilesystem() | ||
{ | ||
if ($this->filesystem === null) { | ||
$this->filesystem = new Filesystem(new Local(__DIR__.'/')); | ||
} | ||
|
||
return $this->filesystem; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,30 @@ | ||
<?php | ||
|
||
namespace Cache\Adapter\Filesystem\tests; | ||
/* | ||
* This file is part of php-cache\filesystem-adapter package. | ||
* | ||
* (c) 2015-2015 Aaron Scherer <aequasi@gmail.com>, Tobias Nyholm <tobias.nyholm@gmail.com> | ||
* | ||
* This source file is subject to the MIT license that is bundled | ||
* with this source code in the file LICENSE. | ||
*/ | ||
|
||
use Cache\Adapter\Filesystem\FilesystemCachePool; | ||
use League\Flysystem\Filesystem; | ||
use League\Flysystem\Adapter\Local; | ||
namespace Cache\Adapter\Filesystem\Tests; | ||
|
||
/** | ||
* @author Tobias Nyholm <tobias.nyholm@gmail.com> | ||
*/ | ||
class FilesystemCachePoolTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
use CreatePoolTrait; | ||
|
||
/** | ||
* @expectedException \Psr\Cache\InvalidArgumentException | ||
*/ | ||
public function testInvalidKey() | ||
{ | ||
$pool = new FilesystemCachePool(new Filesystem(new Local(__DIR__.'/'))); | ||
$pool = $this->createCachePool(); | ||
|
||
$pool->getItem('test%string'); | ||
$pool->getItem('test%string')->get(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters