Skip to content

Commit 37b241e

Browse files
committed
Removed "fallback" feature + opcode optis
1 parent 3a87162 commit 37b241e

8 files changed

Lines changed: 72 additions & 207 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,7 @@
1111
- Added (required) cookie driver option `awareOfUntrustableData` to enforce developer awareness of non-reliable data storage
1212
- The "ActOnAll Helper" have been removed in profit of aggregated cluster support
1313
- Implemented #713 // Reworked "tags" feature by adding 3 strategies: `TAG_STRATEGY_ONE`, `TAG_STRATEGY_ALL`, `TAG_STRATEGY_ONLY`
14-
- Removed *global static* properties `CacheManager::$ReadHits`, `CacheManager::$WriteHits` replaced by`\Phpfastcache\Entities\DriverIO` callable in`\Phpfastcache\Core\Pool\ExtendedCacheItemPoolInterface::getIO`
14+
- Removed *global static* properties `CacheManager::$ReadHits`, `CacheManager::$WriteHits` replaced by`\Phpfastcache\Entities\DriverIO` callable in`\Phpfastcache\Core\Pool\ExtendedCacheItemPoolInterface::getIO`
15+
- Removed deprecated method `ConfigurationOption::getOption()` use `getOptionName()` instead
16+
- Removed deprecated config option `$ignoreSymfonyNotice`
17+
- Removed "fallback" feature (use aggregated cluster Master/Slave instead)

lib/Phpfastcache/CacheManager.php

Lines changed: 6 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -177,16 +177,12 @@ public static function getInstance(string $driver, ?ConfigurationOptionInterface
177177
self::$badPracticeOmeter[$driver] = 1;
178178
$driverClass = self::validateDriverClass(self::getDriverClass($driver));
179179

180-
try {
181-
if (class_exists($driverClass)) {
182-
$configClass = $driverClass::getConfigClass();
183-
self::$instances[$instanceId] = new $driverClass(new $configClass($config->toArray()), $instanceId);
184-
self::$instances[$instanceId]->setEventManager(EventManager::getInstance());
185-
} else {
186-
throw new PhpfastcacheDriverNotFoundException(sprintf('The driver "%s" does not exists', $driver));
187-
}
188-
} catch (PhpfastcacheDriverCheckException $e) {
189-
return self::getFallbackInstance($driver, $config, $e);
180+
if (class_exists($driverClass)) {
181+
$configClass = $driverClass::getConfigClass();
182+
self::$instances[$instanceId] = new $driverClass(new $configClass($config->toArray()), $instanceId);
183+
self::$instances[$instanceId]->setEventManager(EventManager::getInstance());
184+
} else {
185+
throw new PhpfastcacheDriverNotFoundException(sprintf('The driver "%s" does not exists', $driver));
190186
}
191187
} else {
192188
if (self::$badPracticeOmeter[$driver] >= 2) {
@@ -332,35 +328,6 @@ protected static function validateDriverClass(string $driverClass): string
332328
return $driverClass;
333329
}
334330

335-
/**
336-
* @param string $driver
337-
* @param ConfigurationOption $config
338-
* @param PhpfastcacheDriverCheckException $e
339-
* @return ExtendedCacheItemPoolInterface
340-
* @throws PhpfastcacheDriverCheckException
341-
* @throws PhpfastcacheDriverException
342-
* @throws PhpfastcacheDriverNotFoundException
343-
* @throws PhpfastcacheInvalidConfigurationException
344-
* @throws PhpfastcacheLogicException
345-
* @throws \ReflectionException
346-
*/
347-
protected static function getFallbackInstance(string $driver, ConfigurationOption $config, PhpfastcacheDriverCheckException $e): ExtendedCacheItemPoolInterface
348-
{
349-
if ($config->getFallback()) {
350-
try {
351-
$fallback = $config->getFallback();
352-
$config->setFallback('');
353-
trigger_error(sprintf('The "%s" driver is unavailable at the moment, the fallback driver "%s" has been used instead.', $driver,
354-
$fallback), E_USER_WARNING);
355-
return self::getInstance($fallback, $config->getFallbackConfig());
356-
} catch (PhpfastcacheInvalidArgumentException $e) {
357-
throw new PhpfastcacheInvalidConfigurationException('Invalid fallback driver configuration', 0, $e);
358-
}
359-
} else {
360-
throw new PhpfastcacheDriverCheckException($e->getMessage(), $e->getCode(), $e);
361-
}
362-
}
363-
364331
/**
365332
* @return bool
366333
*/

lib/Phpfastcache/Cluster/Drivers/RandomReplication/RandomReplicationCluster.php

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,20 +31,16 @@
3131
class RandomReplicationCluster extends MasterSlaveReplicationCluster
3232
{
3333
/**
34-
* MasterSlaveReplicationCluster constructor.
34+
* RandomReplicationCluster constructor.
3535
* @param string $clusterName
3636
* @param ExtendedCacheItemPoolInterface ...$driverPools
37-
* @throws PhpfastcacheInvalidArgumentException
38-
* @throws PhpfastcacheDriverCheckException
39-
* @throws PhpfastcacheDriverConnectException
40-
* @throws PhpfastcacheInvalidConfigurationException
4137
* @throws ReflectionException
4238
*/
4339
public function __construct(string $clusterName, ExtendedCacheItemPoolInterface ...$driverPools)
4440
{
45-
(new ReflectionMethod(get_parent_class(get_parent_class($this)), __FUNCTION__))
41+
(new ReflectionMethod(\get_parent_class(\get_parent_class($this)), __FUNCTION__))
4642
->invoke($this, $clusterName, ...$driverPools);
47-
$randomPool = $driverPools[random_int(0, count($driverPools) - 1)];
43+
$randomPool = $driverPools[\random_int(0, \count($driverPools) - 1)];
4844
$this->clusterPools = [$randomPool];
4945
}
5046

lib/Phpfastcache/Config/ConfigurationOption.php

Lines changed: 1 addition & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,6 @@ class ConfigurationOption extends ArrayObject implements ConfigurationOptionInte
4040
*/
4141
protected $autoTmpFallback = false;
4242

43-
/**
44-
* @var bool
45-
* @deprecated Do not use this option anymore
46-
*/
47-
protected $ignoreSymfonyNotice = false;
48-
4943
/**
5044
* @var int
5145
*/
@@ -71,16 +65,6 @@ class ConfigurationOption extends ArrayObject implements ConfigurationOptionInte
7165
*/
7266
protected $path = '';
7367

74-
/**
75-
* @var string
76-
*/
77-
protected $fallback = '';
78-
79-
/**
80-
* @var ConfigurationOption
81-
*/
82-
protected $fallbackConfig;
83-
8468
/**
8569
* @var int
8670
*/
@@ -163,17 +147,6 @@ public function __construct(...$args)
163147
}
164148
}
165149

166-
/**
167-
* @param string $optionName
168-
* @return mixed|null
169-
* @deprecated Use ->getOptionName() instead
170-
*/
171-
public function getOption(string $optionName)
172-
{
173-
trigger_error(sprintf('Method "%s" is deprecated, use "getOptionName()" instead', __METHOD__), E_USER_DEPRECATED);
174-
return $this->$optionName ?? null;
175-
}
176-
177150
/**
178151
* @param string $optionName
179152
* @return mixed|null
@@ -219,29 +192,6 @@ public function setAutoTmpFallback(bool $autoTmpFallback): self
219192
return $this;
220193
}
221194

222-
/**
223-
* @return bool
224-
* @deprecated As of V7
225-
*/
226-
public function isIgnoreSymfonyNotice(): bool
227-
{
228-
return $this->ignoreSymfonyNotice;
229-
}
230-
231-
/**
232-
* @param bool $ignoreSymfonyNotice
233-
* @return ConfigurationOption
234-
* @deprecated As of V7
235-
*/
236-
public function setIgnoreSymfonyNotice(bool $ignoreSymfonyNotice): self
237-
{
238-
if ($ignoreSymfonyNotice) {
239-
trigger_error('Configuration option "ignoreSymfonyNotice" is deprecated as of the V7', E_USER_DEPRECATED);
240-
}
241-
$this->ignoreSymfonyNotice = $ignoreSymfonyNotice;
242-
return $this;
243-
}
244-
245195
/**
246196
* @return int
247197
*/
@@ -340,50 +290,6 @@ public function setPath(string $path): self
340290
return $this;
341291
}
342292

343-
/**
344-
* @return bool|string
345-
*/
346-
public function getFallback()
347-
{
348-
return $this->fallback;
349-
}
350-
351-
/**
352-
* @param string $fallback
353-
* @return ConfigurationOption
354-
*/
355-
public function setFallback(string $fallback): self
356-
{
357-
$this->fallback = $fallback;
358-
return $this;
359-
}
360-
361-
/**
362-
* @return ConfigurationOption|null
363-
*/
364-
public function getFallbackConfig()
365-
{
366-
return $this->fallbackConfig;
367-
}
368-
369-
/**
370-
* @param ConfigurationOption|null $fallbackConfig
371-
* @return ConfigurationOption
372-
* @throws PhpfastcacheInvalidArgumentException
373-
*/
374-
public function setFallbackConfig($fallbackConfig): self
375-
{
376-
if ($fallbackConfig !== null && !($fallbackConfig instanceof self)) {
377-
throw new PhpfastcacheInvalidArgumentException(sprintf(
378-
'Invalid argument "%s" for %s',
379-
is_object($fallbackConfig) ? get_class($fallbackConfig) : gettype($fallbackConfig),
380-
__METHOD__
381-
));
382-
}
383-
$this->fallbackConfig = $fallbackConfig;
384-
return $this;
385-
}
386-
387293
/**
388294
* @return int
389295
*/
@@ -455,4 +361,4 @@ public function setCacheSlamsTimeout(int $cacheSlamsTimeout): self
455361
$this->cacheSlamsTimeout = $cacheSlamsTimeout;
456362
return $this;
457363
}
458-
}
364+
}

lib/Phpfastcache/Config/ConfigurationOptionInterface.php

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,9 @@ interface ConfigurationOptionInterface
2424
*/
2525
public function __construct(...$args);
2626

27-
/**
28-
* @param string $optionName
29-
* @return mixed|null
30-
* @deprecated Use ->getOptionName() instead
31-
*/
32-
public function getOption(string $optionName);
33-
3427
/**
3528
* @param string $optionName
3629
* @return mixed|null
3730
*/
3831
public function isValidOption(string $optionName);
39-
}
32+
}

0 commit comments

Comments
 (0)