v 1.4.0
- Updated local libraries - PHP 7.1 support - New, proper caching method - Special cache folder
This commit is contained in:
63
lib/phpfastcache/src/phpFastCache/Drivers/Files/Item.php
Normal file
63
lib/phpfastcache/src/phpFastCache/Drivers/Files/Item.php
Normal file
@ -0,0 +1,63 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of phpFastCache.
|
||||
*
|
||||
* @license MIT License (MIT)
|
||||
*
|
||||
* For full copyright and license information, please see the docs/CREDITS.txt file.
|
||||
*
|
||||
* @author Khoa Bui (khoaofgod) <khoaofgod@gmail.com> http://www.phpfastcache.com
|
||||
* @author Georges.L (Geolim4) <contact@geolim4.com>
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpFastCache\Drivers\Files;
|
||||
|
||||
use phpFastCache\Cache\ExtendedCacheItemInterface;
|
||||
use phpFastCache\Cache\ExtendedCacheItemPoolInterface;
|
||||
use phpFastCache\Cache\ItemBaseTrait;
|
||||
use phpFastCache\Drivers\Files\Driver as FilesDriver;
|
||||
|
||||
/**
|
||||
* Class Item
|
||||
* @package phpFastCache\Drivers\Apc
|
||||
*/
|
||||
class Item implements ExtendedCacheItemInterface
|
||||
{
|
||||
use ItemBaseTrait;
|
||||
|
||||
/**
|
||||
* Item constructor.
|
||||
* @param \phpFastCache\Drivers\Files\Driver $driver
|
||||
* @param $key
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function __construct(FilesDriver $driver, $key)
|
||||
{
|
||||
if (is_string($key)) {
|
||||
$this->expirationDate = new \DateTime();
|
||||
$this->key = $key;
|
||||
$this->driver = $driver;
|
||||
$this->driver->setItem($this);
|
||||
} else {
|
||||
throw new \InvalidArgumentException(sprintf('$key must be a string, got type "%s" instead.', get_class($key)));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ExtendedCacheItemPoolInterface $driver
|
||||
* @throws \InvalidArgumentException
|
||||
* @return static
|
||||
*/
|
||||
public function setDriver(ExtendedCacheItemPoolInterface $driver)
|
||||
{
|
||||
if ($driver instanceof FilesDriver) {
|
||||
$this->driver = $driver;
|
||||
|
||||
return $this;
|
||||
} else {
|
||||
throw new \InvalidArgumentException('Invalid driver instance');
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user