-
Notifications
You must be signed in to change notification settings - Fork 77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Flysystem 2 Storage #138
base: master
Are you sure you want to change the base?
Changes from 3 commits
684d321
dcfe44b
3b7502e
b7e0456
fdc6039
8b6eed5
987e815
ef74fb6
44900e5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?php | ||
|
||
namespace Kevinrob\GuzzleCache\Storage; | ||
|
||
use Kevinrob\GuzzleCache\CacheEntry; | ||
use League\Flysystem\Local\LocalFilesystemAdapter; | ||
use League\Flysystem\Filesystem; | ||
use League\Flysystem\FileNotFoundException; | ||
|
||
class Flysystem2Storage implements CacheStorageInterface | ||
{ | ||
|
||
/** | ||
* @var Filesystem | ||
*/ | ||
protected $filesystem; | ||
|
||
public function __construct(LocalFilesystemAdapter $adapter) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree with @diego-sorribas this shouldnt be fixed to local There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, I 'll try to understand what that means and will fix it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, I think I got it. :) |
||
{ | ||
$this->filesystem = new Filesystem($adapter); | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function fetch($key) | ||
{ | ||
if ($this->filesystem->fileExists($key)) { | ||
// The file exist, read it! | ||
$data = @unserialize( | ||
$this->filesystem->read($key) | ||
); | ||
|
||
if ($data instanceof CacheEntry) { | ||
return $data; | ||
} | ||
} | ||
|
||
return; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this needs to return |
||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function save($key, CacheEntry $data) | ||
{ | ||
return $this->filesystem->write($key, serialize($data)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function delete($key) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Almost the same as above:
|
||
{ | ||
try { | ||
return $this->filesystem->delete($key); | ||
} catch (FileNotFoundException $ex) { | ||
return true; | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Either this should be its own
##
heading or the Flysystem 1 version should also get this 'for xxx' heading.The newer version should be before the older version
If keeping 'for' headings, should be capitalized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just added that.