Proyectos de Subversion Moodle

Rev

Rev 1 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1 Rev 1441
Línea 1... Línea 1...
1
<?php
1
<?php
Línea 2... Línea 2...
2
 
2
 
Línea 3... Línea 3...
3
namespace Kevinrob\GuzzleCache\Storage;
3
namespace Kevinrob\GuzzleCache\Storage;
4
 
-
 
5
use Kevinrob\GuzzleCache\CacheEntry;
4
 
-
 
5
use Kevinrob\GuzzleCache\CacheEntry;
6
use League\Flysystem\AdapterInterface;
6
use League\Flysystem\Filesystem;
Línea 7... Línea 7...
7
use League\Flysystem\Filesystem;
7
use League\Flysystem\FilesystemAdapter;
8
use League\Flysystem\FileNotFoundException;
8
use League\Flysystem\FilesystemException;
Línea 9... Línea 9...
9
 
9
 
10
class FlysystemStorage implements CacheStorageInterface
10
class FlysystemStorage implements CacheStorageInterface
11
{
11
{
12
 
12
 
Línea 13... Línea 13...
13
    /**
13
    /**
14
     * @var Filesystem
14
     * @var Filesystem
15
     */
15
     */
16
    protected $filesystem;
16
    protected $filesystem;
Línea 17... Línea 17...
17
 
17
 
18
    public function __construct(AdapterInterface $adapter)
18
    public function __construct(FilesystemAdapter $adapter)
19
    {
19
    {
20
        $this->filesystem = new Filesystem($adapter);
20
        $this->filesystem = new Filesystem($adapter);
21
    }
21
    }
22
 
22
 
23
    /**
23
    /**
24
     * @inheritdoc
24
     * @inheritdoc
25
     */
25
     */
26
    public function fetch($key)
26
    public function fetch($key)
Línea 42... Línea 42...
42
    /**
42
    /**
43
     * @inheritdoc
43
     * @inheritdoc
44
     */
44
     */
45
    public function save($key, CacheEntry $data)
45
    public function save($key, CacheEntry $data)
46
    {
46
    {
-
 
47
      try {
47
        return $this->filesystem->put($key, serialize($data));
48
        $this->filesystem->write($key, serialize($data));
-
 
49
        return true;
-
 
50
      } catch (FilesystemException $e) {
-
 
51
        return false;
-
 
52
      }
48
    }
53
    }
Línea 49... Línea 54...
49
 
54
 
50
    /**
55
    /**
51
     * {@inheritdoc}
56
     * {@inheritdoc}
52
     */
57
     */
53
    public function delete($key)
58
    public function delete($key)
54
    {
59
    {
55
        try {
60
        try {
-
 
61
            $this->filesystem->delete($key);
56
            return $this->filesystem->delete($key);
62
            return true;
57
        } catch (FileNotFoundException $ex) {
63
        } catch (FilesystemException $ex) {
58
            return true;
64
            return true;
59
        }
65
        }
60
    }
66
    }