v 1.4.0
- Updated local libraries - PHP 7.1 support - New, proper caching method - Special cache folder
This commit is contained in:
136
lib/phpfastcache/src/phpFastCache/Drivers/Devfalse/Driver.php
Normal file
136
lib/phpfastcache/src/phpFastCache/Drivers/Devfalse/Driver.php
Normal file
@ -0,0 +1,136 @@
|
||||
<?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\Devfalse;
|
||||
|
||||
use phpFastCache\Core\DriverAbstract;
|
||||
use phpFastCache\Entities\driverStatistic;
|
||||
use phpFastCache\Exceptions\phpFastCacheDriverCheckException;
|
||||
use phpFastCache\Exceptions\phpFastCacheDriverException;
|
||||
use Psr\Cache\CacheItemInterface;
|
||||
|
||||
/**
|
||||
* Class Driver
|
||||
* @package phpFastCache\Drivers
|
||||
*/
|
||||
class Driver extends DriverAbstract
|
||||
{
|
||||
/**
|
||||
* Driver constructor.
|
||||
* @param array $config
|
||||
* @throws phpFastCacheDriverException
|
||||
*/
|
||||
public function __construct(array $config = [])
|
||||
{
|
||||
$this->setup($config);
|
||||
|
||||
if (!$this->driverCheck()) {
|
||||
throw new phpFastCacheDriverCheckException(sprintf(self::DRIVER_CHECK_FAILURE, $this->getDriverName()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function driverCheck()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Psr\Cache\CacheItemInterface $item
|
||||
* @return mixed
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
protected function driverWrite(CacheItemInterface $item)
|
||||
{
|
||||
/**
|
||||
* Check for Cross-Driver type confusion
|
||||
*/
|
||||
if ($item instanceof Item) {
|
||||
return true;
|
||||
} else {
|
||||
throw new \InvalidArgumentException('Cross-Driver type confusion detected');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Psr\Cache\CacheItemInterface $item
|
||||
* @return array [
|
||||
* 'd' => 'THE ITEM DATA'
|
||||
* 't' => 'THE ITEM DATE EXPIRATION'
|
||||
* 'g' => 'THE ITEM TAGS'
|
||||
* ]
|
||||
*/
|
||||
protected function driverRead(CacheItemInterface $item)
|
||||
{
|
||||
return [
|
||||
self::DRIVER_DATA_WRAPPER_INDEX => false,
|
||||
self::DRIVER_TAGS_WRAPPER_INDEX => [],
|
||||
self::DRIVER_TIME_WRAPPER_INDEX => new \DateTime(),
|
||||
];
|
||||
}
|
||||
/**
|
||||
* @param \Psr\Cache\CacheItemInterface $item
|
||||
* @return bool
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
protected function driverDelete(CacheItemInterface $item)
|
||||
{
|
||||
/**
|
||||
* Check for Cross-Driver type confusion
|
||||
*/
|
||||
if ($item instanceof Item) {
|
||||
return true;
|
||||
} else {
|
||||
throw new \InvalidArgumentException('Cross-Driver type confusion detected');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function driverClear()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function driverConnect()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/********************
|
||||
*
|
||||
* PSR-6 Extended Methods
|
||||
*
|
||||
*******************/
|
||||
|
||||
/**
|
||||
* @return driverStatistic
|
||||
*/
|
||||
public function getStats()
|
||||
{
|
||||
$stat = new driverStatistic();
|
||||
$stat->setInfo('[Devfalse] A void info string')
|
||||
->setSize(0)
|
||||
->setData(implode(', ', array_keys($this->itemInstances)))
|
||||
->setRawData(false);
|
||||
|
||||
return $stat;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user