PHP Classes

File: application/modules/extensions/aws/Aws/PsrCacheAdapter.php

Recommend this page to a friend!
  Classes of Tran Tuan   Pretty PHP S3 Files Manager   application/modules/extensions/aws/Aws/PsrCacheAdapter.php   Download  
File: application/modules/extensions/aws/Aws/PsrCacheAdapter.php
Role: Application script
Content type: text/plain
Description: Initial
Class: Pretty PHP S3 Files Manager
Web based interface to manage files in Amazon S3
Author: By
Last change:
Date: 8 years ago
Size: 742 bytes
 

Contents

Class file image Download
<?php
namespace Aws;

use
Psr\Cache\CacheItemPoolInterface;

class
PsrCacheAdapter implements CacheInterface
{
   
/** @var CacheItemPoolInterface */
   
private $pool;

    public function
__construct(CacheItemPoolInterface $pool)
    {
       
$this->pool = $pool;
    }

    public function
get($key)
    {
       
$item = $this->pool->getItem($key);

        return
$item->isHit() ? $item->get() : null;
    }

    public function
set($key, $value, $ttl = 0)
    {
       
$item = $this->pool->getItem($key);
       
$item->set($value);
        if (
$ttl > 0) {
           
$item->expiresAfter($ttl);
        }

       
$this->pool->save($item);
    }

    public function
remove($key)
    {
       
$this->pool->deleteItem($key);
    }
}