initial commit; version 22.5.12042

This commit is contained in:
2022-12-12 23:28:25 -05:00
commit af1b03d79f
17653 changed files with 22692970 additions and 0 deletions

View File

@ -0,0 +1,24 @@
<?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> https://www.phpfastcache.com
* @author Georges.L (Geolim4) <contact@geolim4.com>
*
*/
declare(strict_types=1);
namespace Phpfastcache\Drivers\Zenddisk;
use Phpfastcache\Config\ConfigurationOption;
class Config extends ConfigurationOption
{
}

View File

@ -0,0 +1,141 @@
<?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 Lucas Brucksch <support@hammermaps.de>
*
*/
declare(strict_types=1);
namespace Phpfastcache\Drivers\Zenddisk;
use Phpfastcache\Cluster\AggregatablePoolInterface;
use Phpfastcache\Core\Pool\{DriverBaseTrait, ExtendedCacheItemPoolInterface};
use Phpfastcache\Entities\DriverStatistic;
use Phpfastcache\Exceptions\{PhpfastcacheInvalidArgumentException};
use Psr\Cache\CacheItemInterface;
/**
* Class Driver (zend disk cache)
* Requires Zend Data Cache Functions from ZendServer
* @package phpFastCache\Drivers
* @property Config $config Config object
* @method Config getConfig() Return the config object
*/
class Driver implements ExtendedCacheItemPoolInterface, AggregatablePoolInterface
{
use DriverBaseTrait;
/**
* @return bool
*/
public function driverCheck(): bool
{
return extension_loaded('Zend Data Cache') && function_exists('zend_disk_cache_store');
}
/**
* @return string
*/
public function getHelp(): string
{
return <<<HELP
<p>
This driver rely on Zend Server 8.5+, see: https://www.zend.com/en/products/zend_server
</p>
HELP;
}
/**
* @return DriverStatistic
*/
public function getStats(): DriverStatistic
{
$stat = new DriverStatistic();
$stat->setInfo('[ZendDisk] A void info string')
->setSize(0)
->setData(implode(', ', array_keys($this->itemInstances)))
->setRawData(false);
return $stat;
}
/**
* @return bool
*/
protected function driverConnect(): bool
{
return true;
}
/**
* @param CacheItemInterface $item
* @return null|array
*/
protected function driverRead(CacheItemInterface $item)
{
$data = zend_disk_cache_fetch($item->getKey());
if ($data === false) {
return null;
}
return $data;
}
/**
* @param CacheItemInterface $item
* @return mixed
* @throws PhpfastcacheInvalidArgumentException
*/
protected function driverWrite(CacheItemInterface $item): bool
{
/**
* Check for Cross-Driver type confusion
*/
if ($item instanceof Item) {
$ttl = $item->getExpirationDate()->getTimestamp() - time();
return zend_disk_cache_store($item->getKey(), $this->driverPreWrap($item), ($ttl > 0 ? $ttl : 0));
}
throw new PhpfastcacheInvalidArgumentException('Cross-Driver type confusion detected');
}
/********************
*
* PSR-6 Extended Methods
*
*******************/
/**
* @param CacheItemInterface $item
* @return bool
* @throws PhpfastcacheInvalidArgumentException
*/
protected function driverDelete(CacheItemInterface $item): bool
{
/**
* Check for Cross-Driver type confusion
*/
if ($item instanceof Item) {
return (bool)zend_disk_cache_delete($item->getKey());
}
throw new PhpfastcacheInvalidArgumentException('Cross-Driver type confusion detected');
}
/**
* @return bool
*/
protected function driverClear(): bool
{
return @zend_disk_cache_clear();
}
}

View File

@ -0,0 +1,60 @@
<?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 Lucas Brucksch <support@hammermaps.de>
*
*/
declare(strict_types=1);
namespace Phpfastcache\Drivers\Zenddisk;
use Phpfastcache\Core\Item\{ExtendedCacheItemInterface, ItemBaseTrait};
use Phpfastcache\Core\Pool\ExtendedCacheItemPoolInterface;
use Phpfastcache\Drivers\Zenddisk\Driver as ZendDiskDriver;
use Phpfastcache\Exceptions\{PhpfastcacheInvalidArgumentException};
/**
* Class Item
* @package phpFastCache\Drivers\Zenddisk
*/
class Item implements ExtendedCacheItemInterface
{
use ItemBaseTrait {
ItemBaseTrait::__construct as __BaseConstruct;
}
/**
* Item constructor.
* @param Driver $driver
* @param $key
* @throws PhpfastcacheInvalidArgumentException
*/
public function __construct(ZendDiskDriver $driver, $key)
{
$this->__BaseConstruct($driver, $key);
}
/**
* @param ExtendedCacheItemPoolInterface $driver
* @return static
* @throws PhpfastcacheInvalidArgumentException
*/
public function setDriver(ExtendedCacheItemPoolInterface $driver)
{
if ($driver instanceof ZendDiskDriver) {
$this->driver = $driver;
return $this;
}
throw new PhpfastcacheInvalidArgumentException('Invalid driver instance');
}
}