Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
<?php
2
namespace Aws;
3
 
4
use Psr\Cache\CacheItemPoolInterface;
5
 
6
class PsrCacheAdapter implements CacheInterface
7
{
8
    /** @var CacheItemPoolInterface */
9
    private $pool;
10
 
11
    public function __construct(CacheItemPoolInterface $pool)
12
    {
13
        $this->pool = $pool;
14
    }
15
 
16
    public function get($key)
17
    {
18
        $item = $this->pool->getItem($key);
19
 
20
        return $item->isHit() ? $item->get() : null;
21
    }
22
 
23
    public function set($key, $value, $ttl = 0)
24
    {
25
        $item = $this->pool->getItem($key);
26
        $item->set($value);
27
        if ($ttl > 0) {
28
            $item->expiresAfter($ttl);
29
        }
30
 
31
        $this->pool->save($item);
32
    }
33
 
34
    public function remove($key)
35
    {
36
        $this->pool->deleteItem($key);
37
    }
38
}