@@ -30,141 +30,141 @@ |
||
| 30 | 30 | |
| 31 | 31 | class ClusterAggregator implements AggregatorInterface |
| 32 | 32 | { |
| 33 | - /** |
|
| 34 | - * @var array<string, AggregatablePoolInterface> |
|
| 35 | - */ |
|
| 36 | - protected array $driverPools; |
|
| 37 | - |
|
| 38 | - protected ClusterPoolInterface $cluster; |
|
| 39 | - |
|
| 40 | - protected string $clusterAggregatorName; |
|
| 41 | - |
|
| 42 | - /** |
|
| 43 | - * ClusterAggregator constructor. |
|
| 44 | - * @param string $clusterAggregatorName |
|
| 45 | - * @param array<AggregatablePoolInterface> $driverPools |
|
| 46 | - * @throws PhpfastcacheLogicException |
|
| 47 | - */ |
|
| 48 | - public function __construct(string $clusterAggregatorName = '', AggregatablePoolInterface ...$driverPools) |
|
| 49 | - { |
|
| 50 | - $clusterAggregatorName = trim($clusterAggregatorName); |
|
| 51 | - if (empty($clusterAggregatorName)) { |
|
| 52 | - try { |
|
| 53 | - $clusterAggregatorName = 'cluster_' . \bin2hex(\random_bytes(15)); |
|
| 54 | - } catch (Exception) { |
|
| 55 | - $clusterAggregatorName = 'cluster_' . \str_shuffle(\spl_object_hash(new stdClass())); |
|
| 56 | - } |
|
| 57 | - } |
|
| 58 | - |
|
| 59 | - $this->clusterAggregatorName = $clusterAggregatorName; |
|
| 60 | - |
|
| 61 | - foreach ($driverPools as $driverPool) { |
|
| 62 | - $this->aggregateDriver($driverPool); |
|
| 63 | - } |
|
| 64 | - } |
|
| 65 | - |
|
| 66 | - /** |
|
| 67 | - * @param AggregatablePoolInterface $driverPool |
|
| 68 | - * |
|
| 69 | - * @throws PhpfastcacheLogicException |
|
| 70 | - */ |
|
| 71 | - public function aggregateDriver(AggregatablePoolInterface $driverPool): void |
|
| 72 | - { |
|
| 73 | - if (isset($this->cluster)) { |
|
| 74 | - throw new PhpfastcacheLogicException('The cluster has been already build, cannot aggregate more pools.'); |
|
| 75 | - } |
|
| 76 | - |
|
| 77 | - $splHash = \spl_object_hash($driverPool); |
|
| 78 | - if (!isset($this->driverPools[$splHash])) { |
|
| 79 | - if ($driverPool instanceof ClusterPoolInterface) { |
|
| 80 | - throw new PhpfastcacheLogicException('Recursive cluster aggregation is not allowed !'); |
|
| 81 | - } |
|
| 82 | - |
|
| 83 | - $this->driverPools[$splHash] = $driverPool; |
|
| 84 | - } else { |
|
| 85 | - throw new PhpfastcacheLogicException('This pool has been already aggregated !'); |
|
| 86 | - } |
|
| 87 | - } |
|
| 88 | - |
|
| 89 | - /** |
|
| 90 | - * @param string $driverName |
|
| 91 | - * @param ConfigurationOption|null $driverConfig |
|
| 92 | - * @throws PhpfastcacheDriverCheckException |
|
| 93 | - * @throws PhpfastcacheDriverException |
|
| 94 | - * @throws PhpfastcacheDriverNotFoundException |
|
| 95 | - * @throws PhpfastcacheLogicException |
|
| 96 | - */ |
|
| 97 | - public function aggregateDriverByName(string $driverName, ConfigurationOption $driverConfig = null): void |
|
| 98 | - { |
|
| 99 | - if (isset($this->cluster)) { |
|
| 100 | - throw new PhpfastcacheLogicException('The cluster has been already build, cannot aggregate more pools.'); |
|
| 101 | - } |
|
| 102 | - |
|
| 103 | - $driverInstance = CacheManager::getInstance($driverName, $driverConfig); |
|
| 104 | - |
|
| 105 | - if ($driverInstance instanceof AggregatablePoolInterface) { |
|
| 106 | - $this->aggregateDriver($driverInstance); |
|
| 107 | - } |
|
| 108 | - |
|
| 109 | - throw new PhpfastcacheDriverException( |
|
| 110 | - \sprintf( |
|
| 111 | - 'Driver "%s" does not implements "%s"', |
|
| 112 | - $driverInstance::class, |
|
| 113 | - AggregatablePoolInterface::class |
|
| 114 | - ) |
|
| 115 | - ); |
|
| 116 | - } |
|
| 117 | - |
|
| 118 | - /** |
|
| 119 | - * @param AggregatablePoolInterface $driverPool |
|
| 120 | - * |
|
| 121 | - * @throws PhpfastcacheLogicException |
|
| 122 | - */ |
|
| 123 | - public function disaggregateDriver(AggregatablePoolInterface $driverPool): void |
|
| 124 | - { |
|
| 125 | - if (isset($this->cluster)) { |
|
| 126 | - throw new PhpfastcacheLogicException('The cluster has been already build, cannot disaggregate pools.'); |
|
| 127 | - } |
|
| 128 | - |
|
| 129 | - $splHash = \spl_object_hash($driverPool); |
|
| 130 | - if (isset($this->driverPools[$splHash])) { |
|
| 131 | - unset($this->driverPools[$splHash]); |
|
| 132 | - } else { |
|
| 133 | - throw new PhpfastcacheLogicException('This pool was not aggregated !'); |
|
| 134 | - } |
|
| 135 | - } |
|
| 136 | - |
|
| 137 | - /** |
|
| 138 | - * @param int $strategy |
|
| 139 | - * |
|
| 140 | - * @return ClusterPoolInterface |
|
| 141 | - * @throws PhpfastcacheInvalidArgumentException |
|
| 142 | - */ |
|
| 143 | - public function getCluster(int $strategy = AggregatorInterface::STRATEGY_FULL_REPLICATION): ClusterPoolInterface |
|
| 144 | - { |
|
| 145 | - if (isset(ClusterPoolAbstract::STRATEGY[$strategy])) { |
|
| 146 | - if (!isset($this->cluster)) { |
|
| 147 | - $clusterClass = ClusterPoolAbstract::STRATEGY[$strategy]; |
|
| 148 | - $this->cluster = new $clusterClass( |
|
| 149 | - $this->getClusterAggregatorName(), |
|
| 150 | - EventManager::getInstance(), |
|
| 151 | - ...\array_values($this->driverPools) |
|
| 152 | - ); |
|
| 153 | - |
|
| 154 | - $this->cluster->getEventManager()->dispatch(Event::CACHE_CLUSTER_BUILT, $this, $this->cluster); |
|
| 155 | - } |
|
| 156 | - } else { |
|
| 157 | - throw new PhpfastcacheInvalidArgumentException('Unknown cluster strategy'); |
|
| 158 | - } |
|
| 159 | - |
|
| 160 | - return $this->cluster; |
|
| 161 | - } |
|
| 162 | - |
|
| 163 | - /** |
|
| 164 | - * @return string |
|
| 165 | - */ |
|
| 166 | - public function getClusterAggregatorName(): string |
|
| 167 | - { |
|
| 168 | - return $this->clusterAggregatorName; |
|
| 169 | - } |
|
| 33 | + /** |
|
| 34 | + * @var array<string, AggregatablePoolInterface> |
|
| 35 | + */ |
|
| 36 | + protected array $driverPools; |
|
| 37 | + |
|
| 38 | + protected ClusterPoolInterface $cluster; |
|
| 39 | + |
|
| 40 | + protected string $clusterAggregatorName; |
|
| 41 | + |
|
| 42 | + /** |
|
| 43 | + * ClusterAggregator constructor. |
|
| 44 | + * @param string $clusterAggregatorName |
|
| 45 | + * @param array<AggregatablePoolInterface> $driverPools |
|
| 46 | + * @throws PhpfastcacheLogicException |
|
| 47 | + */ |
|
| 48 | + public function __construct(string $clusterAggregatorName = '', AggregatablePoolInterface ...$driverPools) |
|
| 49 | + { |
|
| 50 | + $clusterAggregatorName = trim($clusterAggregatorName); |
|
| 51 | + if (empty($clusterAggregatorName)) { |
|
| 52 | + try { |
|
| 53 | + $clusterAggregatorName = 'cluster_' . \bin2hex(\random_bytes(15)); |
|
| 54 | + } catch (Exception) { |
|
| 55 | + $clusterAggregatorName = 'cluster_' . \str_shuffle(\spl_object_hash(new stdClass())); |
|
| 56 | + } |
|
| 57 | + } |
|
| 58 | + |
|
| 59 | + $this->clusterAggregatorName = $clusterAggregatorName; |
|
| 60 | + |
|
| 61 | + foreach ($driverPools as $driverPool) { |
|
| 62 | + $this->aggregateDriver($driverPool); |
|
| 63 | + } |
|
| 64 | + } |
|
| 65 | + |
|
| 66 | + /** |
|
| 67 | + * @param AggregatablePoolInterface $driverPool |
|
| 68 | + * |
|
| 69 | + * @throws PhpfastcacheLogicException |
|
| 70 | + */ |
|
| 71 | + public function aggregateDriver(AggregatablePoolInterface $driverPool): void |
|
| 72 | + { |
|
| 73 | + if (isset($this->cluster)) { |
|
| 74 | + throw new PhpfastcacheLogicException('The cluster has been already build, cannot aggregate more pools.'); |
|
| 75 | + } |
|
| 76 | + |
|
| 77 | + $splHash = \spl_object_hash($driverPool); |
|
| 78 | + if (!isset($this->driverPools[$splHash])) { |
|
| 79 | + if ($driverPool instanceof ClusterPoolInterface) { |
|
| 80 | + throw new PhpfastcacheLogicException('Recursive cluster aggregation is not allowed !'); |
|
| 81 | + } |
|
| 82 | + |
|
| 83 | + $this->driverPools[$splHash] = $driverPool; |
|
| 84 | + } else { |
|
| 85 | + throw new PhpfastcacheLogicException('This pool has been already aggregated !'); |
|
| 86 | + } |
|
| 87 | + } |
|
| 88 | + |
|
| 89 | + /** |
|
| 90 | + * @param string $driverName |
|
| 91 | + * @param ConfigurationOption|null $driverConfig |
|
| 92 | + * @throws PhpfastcacheDriverCheckException |
|
| 93 | + * @throws PhpfastcacheDriverException |
|
| 94 | + * @throws PhpfastcacheDriverNotFoundException |
|
| 95 | + * @throws PhpfastcacheLogicException |
|
| 96 | + */ |
|
| 97 | + public function aggregateDriverByName(string $driverName, ConfigurationOption $driverConfig = null): void |
|
| 98 | + { |
|
| 99 | + if (isset($this->cluster)) { |
|
| 100 | + throw new PhpfastcacheLogicException('The cluster has been already build, cannot aggregate more pools.'); |
|
| 101 | + } |
|
| 102 | + |
|
| 103 | + $driverInstance = CacheManager::getInstance($driverName, $driverConfig); |
|
| 104 | + |
|
| 105 | + if ($driverInstance instanceof AggregatablePoolInterface) { |
|
| 106 | + $this->aggregateDriver($driverInstance); |
|
| 107 | + } |
|
| 108 | + |
|
| 109 | + throw new PhpfastcacheDriverException( |
|
| 110 | + \sprintf( |
|
| 111 | + 'Driver "%s" does not implements "%s"', |
|
| 112 | + $driverInstance::class, |
|
| 113 | + AggregatablePoolInterface::class |
|
| 114 | + ) |
|
| 115 | + ); |
|
| 116 | + } |
|
| 117 | + |
|
| 118 | + /** |
|
| 119 | + * @param AggregatablePoolInterface $driverPool |
|
| 120 | + * |
|
| 121 | + * @throws PhpfastcacheLogicException |
|
| 122 | + */ |
|
| 123 | + public function disaggregateDriver(AggregatablePoolInterface $driverPool): void |
|
| 124 | + { |
|
| 125 | + if (isset($this->cluster)) { |
|
| 126 | + throw new PhpfastcacheLogicException('The cluster has been already build, cannot disaggregate pools.'); |
|
| 127 | + } |
|
| 128 | + |
|
| 129 | + $splHash = \spl_object_hash($driverPool); |
|
| 130 | + if (isset($this->driverPools[$splHash])) { |
|
| 131 | + unset($this->driverPools[$splHash]); |
|
| 132 | + } else { |
|
| 133 | + throw new PhpfastcacheLogicException('This pool was not aggregated !'); |
|
| 134 | + } |
|
| 135 | + } |
|
| 136 | + |
|
| 137 | + /** |
|
| 138 | + * @param int $strategy |
|
| 139 | + * |
|
| 140 | + * @return ClusterPoolInterface |
|
| 141 | + * @throws PhpfastcacheInvalidArgumentException |
|
| 142 | + */ |
|
| 143 | + public function getCluster(int $strategy = AggregatorInterface::STRATEGY_FULL_REPLICATION): ClusterPoolInterface |
|
| 144 | + { |
|
| 145 | + if (isset(ClusterPoolAbstract::STRATEGY[$strategy])) { |
|
| 146 | + if (!isset($this->cluster)) { |
|
| 147 | + $clusterClass = ClusterPoolAbstract::STRATEGY[$strategy]; |
|
| 148 | + $this->cluster = new $clusterClass( |
|
| 149 | + $this->getClusterAggregatorName(), |
|
| 150 | + EventManager::getInstance(), |
|
| 151 | + ...\array_values($this->driverPools) |
|
| 152 | + ); |
|
| 153 | + |
|
| 154 | + $this->cluster->getEventManager()->dispatch(Event::CACHE_CLUSTER_BUILT, $this, $this->cluster); |
|
| 155 | + } |
|
| 156 | + } else { |
|
| 157 | + throw new PhpfastcacheInvalidArgumentException('Unknown cluster strategy'); |
|
| 158 | + } |
|
| 159 | + |
|
| 160 | + return $this->cluster; |
|
| 161 | + } |
|
| 162 | + |
|
| 163 | + /** |
|
| 164 | + * @return string |
|
| 165 | + */ |
|
| 166 | + public function getClusterAggregatorName(): string |
|
| 167 | + { |
|
| 168 | + return $this->clusterAggregatorName; |
|
| 169 | + } |
|
| 170 | 170 | } |
@@ -21,13 +21,13 @@ |
||
| 21 | 21 | |
| 22 | 22 | interface ClusterPoolInterface extends ExtendedCacheItemPoolInterface |
| 23 | 23 | { |
| 24 | - /** |
|
| 25 | - * @return AggregatablePoolInterface[] |
|
| 26 | - */ |
|
| 27 | - public function getClusterPools(): array; |
|
| 24 | + /** |
|
| 25 | + * @return AggregatablePoolInterface[] |
|
| 26 | + */ |
|
| 27 | + public function getClusterPools(): array; |
|
| 28 | 28 | |
| 29 | - /** |
|
| 30 | - * @return ConfigurationOptionInterface[] |
|
| 31 | - */ |
|
| 32 | - public function getConfigs(): array; |
|
| 29 | + /** |
|
| 30 | + * @return ConfigurationOptionInterface[] |
|
| 31 | + */ |
|
| 32 | + public function getConfigs(): array; |
|
| 33 | 33 | } |
@@ -21,5 +21,5 @@ |
||
| 21 | 21 | |
| 22 | 22 | abstract class ItemAbstract implements ExtendedCacheItemInterface |
| 23 | 23 | { |
| 24 | - use TaggableCacheItemTrait; |
|
| 24 | + use TaggableCacheItemTrait; |
|
| 25 | 25 | } |
@@ -21,49 +21,49 @@ |
||
| 21 | 21 | |
| 22 | 22 | trait ClusterPoolTrait |
| 23 | 23 | { |
| 24 | - protected function driverCheck(): bool |
|
| 25 | - { |
|
| 26 | - return true; |
|
| 27 | - } |
|
| 24 | + protected function driverCheck(): bool |
|
| 25 | + { |
|
| 26 | + return true; |
|
| 27 | + } |
|
| 28 | 28 | |
| 29 | - protected function driverConnect(): bool |
|
| 30 | - { |
|
| 31 | - return true; |
|
| 32 | - } |
|
| 29 | + protected function driverConnect(): bool |
|
| 30 | + { |
|
| 31 | + return true; |
|
| 32 | + } |
|
| 33 | 33 | |
| 34 | - /** |
|
| 35 | - * @param ExtendedCacheItemInterface $item |
|
| 36 | - * @return ?array<string, mixed> |
|
| 37 | - */ |
|
| 38 | - protected function driverRead(ExtendedCacheItemInterface $item): ?array |
|
| 39 | - { |
|
| 40 | - return null; |
|
| 41 | - } |
|
| 34 | + /** |
|
| 35 | + * @param ExtendedCacheItemInterface $item |
|
| 36 | + * @return ?array<string, mixed> |
|
| 37 | + */ |
|
| 38 | + protected function driverRead(ExtendedCacheItemInterface $item): ?array |
|
| 39 | + { |
|
| 40 | + return null; |
|
| 41 | + } |
|
| 42 | 42 | |
| 43 | - /** |
|
| 44 | - * @param ExtendedCacheItemInterface $item |
|
| 45 | - * @return bool |
|
| 46 | - */ |
|
| 47 | - protected function driverWrite(ExtendedCacheItemInterface $item): bool |
|
| 48 | - { |
|
| 49 | - return true; |
|
| 50 | - } |
|
| 43 | + /** |
|
| 44 | + * @param ExtendedCacheItemInterface $item |
|
| 45 | + * @return bool |
|
| 46 | + */ |
|
| 47 | + protected function driverWrite(ExtendedCacheItemInterface $item): bool |
|
| 48 | + { |
|
| 49 | + return true; |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | - /** |
|
| 53 | - * @param string $key |
|
| 54 | - * @param string $encodedKey |
|
| 55 | - * @return bool |
|
| 56 | - */ |
|
| 57 | - protected function driverDelete(string $key, string $encodedKey): bool |
|
| 58 | - { |
|
| 59 | - return true; |
|
| 60 | - } |
|
| 52 | + /** |
|
| 53 | + * @param string $key |
|
| 54 | + * @param string $encodedKey |
|
| 55 | + * @return bool |
|
| 56 | + */ |
|
| 57 | + protected function driverDelete(string $key, string $encodedKey): bool |
|
| 58 | + { |
|
| 59 | + return true; |
|
| 60 | + } |
|
| 61 | 61 | |
| 62 | - /** |
|
| 63 | - * @return bool |
|
| 64 | - */ |
|
| 65 | - protected function driverClear(): bool |
|
| 66 | - { |
|
| 67 | - return true; |
|
| 68 | - } |
|
| 62 | + /** |
|
| 63 | + * @return bool |
|
| 64 | + */ |
|
| 65 | + protected function driverClear(): bool |
|
| 66 | + { |
|
| 67 | + return true; |
|
| 68 | + } |
|
| 69 | 69 | } |
@@ -20,37 +20,37 @@ |
||
| 20 | 20 | |
| 21 | 21 | class EventReferenceParameter |
| 22 | 22 | { |
| 23 | - public function __construct(protected mixed &$parameter, protected bool $allowTypeChange = false) |
|
| 24 | - { |
|
| 25 | - } |
|
| 26 | - |
|
| 27 | - public function getParameterValue(): mixed |
|
| 28 | - { |
|
| 29 | - return $this->parameter; |
|
| 30 | - } |
|
| 31 | - |
|
| 32 | - /** |
|
| 33 | - * @throws PhpfastcacheInvalidTypeException |
|
| 34 | - */ |
|
| 35 | - public function setParameterValue(mixed $newValue): void |
|
| 36 | - { |
|
| 37 | - if (!$this->allowTypeChange) { |
|
| 38 | - $currentType = \gettype($this->parameter); |
|
| 39 | - $newType = \gettype($newValue); |
|
| 40 | - if ($newType !== $currentType) { |
|
| 41 | - throw new PhpfastcacheInvalidTypeException(\sprintf( |
|
| 42 | - 'You tried to change the variable type from "%s" to "%s", which is not allowed.', |
|
| 43 | - $currentType, |
|
| 44 | - $newType |
|
| 45 | - )); |
|
| 46 | - } |
|
| 47 | - } |
|
| 48 | - |
|
| 49 | - $this->parameter = $newValue; |
|
| 50 | - } |
|
| 51 | - |
|
| 52 | - public function __invoke(): mixed |
|
| 53 | - { |
|
| 54 | - return $this->getParameterValue(); |
|
| 55 | - } |
|
| 23 | + public function __construct(protected mixed &$parameter, protected bool $allowTypeChange = false) |
|
| 24 | + { |
|
| 25 | + } |
|
| 26 | + |
|
| 27 | + public function getParameterValue(): mixed |
|
| 28 | + { |
|
| 29 | + return $this->parameter; |
|
| 30 | + } |
|
| 31 | + |
|
| 32 | + /** |
|
| 33 | + * @throws PhpfastcacheInvalidTypeException |
|
| 34 | + */ |
|
| 35 | + public function setParameterValue(mixed $newValue): void |
|
| 36 | + { |
|
| 37 | + if (!$this->allowTypeChange) { |
|
| 38 | + $currentType = \gettype($this->parameter); |
|
| 39 | + $newType = \gettype($newValue); |
|
| 40 | + if ($newType !== $currentType) { |
|
| 41 | + throw new PhpfastcacheInvalidTypeException(\sprintf( |
|
| 42 | + 'You tried to change the variable type from "%s" to "%s", which is not allowed.', |
|
| 43 | + $currentType, |
|
| 44 | + $newType |
|
| 45 | + )); |
|
| 46 | + } |
|
| 47 | + } |
|
| 48 | + |
|
| 49 | + $this->parameter = $newValue; |
|
| 50 | + } |
|
| 51 | + |
|
| 52 | + public function __invoke(): mixed |
|
| 53 | + { |
|
| 54 | + return $this->getParameterValue(); |
|
| 55 | + } |
|
| 56 | 56 | } |
@@ -18,34 +18,34 @@ |
||
| 18 | 18 | |
| 19 | 19 | trait EventManagerDispatcherTrait |
| 20 | 20 | { |
| 21 | - /** |
|
| 22 | - * @var EventManagerInterface |
|
| 23 | - */ |
|
| 24 | - protected EventManagerInterface $eventManager; |
|
| 21 | + /** |
|
| 22 | + * @var EventManagerInterface |
|
| 23 | + */ |
|
| 24 | + protected EventManagerInterface $eventManager; |
|
| 25 | 25 | /** |
| 26 | - * @return EventManagerInterface |
|
| 27 | - */ |
|
| 28 | - public function getEventManager(): EventManagerInterface |
|
| 29 | - { |
|
| 30 | - return $this->eventManager; |
|
| 31 | - } |
|
| 26 | + * @return EventManagerInterface |
|
| 27 | + */ |
|
| 28 | + public function getEventManager(): EventManagerInterface |
|
| 29 | + { |
|
| 30 | + return $this->eventManager; |
|
| 31 | + } |
|
| 32 | 32 | |
| 33 | - /** |
|
| 34 | - * @param EventManagerInterface $em |
|
| 35 | - * @return static |
|
| 36 | - */ |
|
| 37 | - public function setEventManager(EventManagerInterface $em): static |
|
| 38 | - { |
|
| 39 | - $this->eventManager = $em; |
|
| 40 | - return $this; |
|
| 41 | - } |
|
| 33 | + /** |
|
| 34 | + * @param EventManagerInterface $em |
|
| 35 | + * @return static |
|
| 36 | + */ |
|
| 37 | + public function setEventManager(EventManagerInterface $em): static |
|
| 38 | + { |
|
| 39 | + $this->eventManager = $em; |
|
| 40 | + return $this; |
|
| 41 | + } |
|
| 42 | 42 | |
| 43 | - /** |
|
| 44 | - * @deprecated Will be removed in v10 |
|
| 45 | - * @return bool |
|
| 46 | - */ |
|
| 47 | - public function hasEventManager(): bool |
|
| 48 | - { |
|
| 49 | - return isset($this->eventManager); |
|
| 50 | - } |
|
| 43 | + /** |
|
| 44 | + * @deprecated Will be removed in v10 |
|
| 45 | + * @return bool |
|
| 46 | + */ |
|
| 47 | + public function hasEventManager(): bool |
|
| 48 | + { |
|
| 49 | + return isset($this->eventManager); |
|
| 50 | + } |
|
| 51 | 51 | } |
@@ -20,31 +20,31 @@ |
||
| 20 | 20 | |
| 21 | 21 | class Event implements EventInterface |
| 22 | 22 | { |
| 23 | - use UninstanciableObjectTrait; |
|
| 23 | + use UninstanciableObjectTrait; |
|
| 24 | 24 | |
| 25 | - public const CACHE_GET_ITEM = 'CacheGetItem'; |
|
| 26 | - public const CACHE_GET_ITEMS = 'CacheGetItems'; |
|
| 27 | - public const CACHE_DELETE_ITEM = 'CacheDeleteItem'; |
|
| 28 | - public const CACHE_DELETE_ITEMS = 'CacheDeleteItems'; |
|
| 29 | - public const CACHE_SAVE_ITEM = 'CacheSaveItem'; |
|
| 30 | - public const CACHE_SAVE_MULTIPLE_ITEMS = 'CacheSaveMultipleItems'; |
|
| 31 | - public const CACHE_SAVE_DEFERRED_ITEM = 'CacheSaveDeferredItem'; |
|
| 32 | - public const CACHE_COMMIT_ITEM = 'CacheCommitItem'; |
|
| 33 | - public const CACHE_CLEAR_ITEM = 'CacheClearItem'; |
|
| 34 | - public const CACHE_WRITE_FILE_ON_DISK = 'CacheWriteFileOnDisk'; |
|
| 35 | - public const CACHE_GET_ITEM_IN_SLAM_BATCH = 'CacheGetItemInSlamBatch'; |
|
| 36 | - public const CACHE_REPLICATION_SLAVE_FALLBACK = 'CacheReplicationSlaveFallback'; |
|
| 37 | - public const CACHE_REPLICATION_RANDOM_POOL_CHOSEN = 'CacheReplicationRandomPoolChosen'; |
|
| 38 | - public const CACHE_CLUSTER_BUILT = 'CacheClusterBuilt'; |
|
| 39 | - public const CACHE_ITEM_SET = 'CacheItemSet'; |
|
| 40 | - public const CACHE_ITEM_EXPIRE_AT = 'CacheItemExpireAt'; |
|
| 41 | - public const CACHE_ITEM_EXPIRE_AFTER = 'CacheItemExpireAfter'; |
|
| 42 | - public const CACHE_GET_ALL_ITEMS = 'CacheGetAllItems'; |
|
| 43 | - public const CACHE_DRIVER_CHECKED = 'CacheDriverChecked'; |
|
| 44 | - public const CACHE_DRIVER_CONNECTED = 'CacheDriverConnected'; |
|
| 25 | + public const CACHE_GET_ITEM = 'CacheGetItem'; |
|
| 26 | + public const CACHE_GET_ITEMS = 'CacheGetItems'; |
|
| 27 | + public const CACHE_DELETE_ITEM = 'CacheDeleteItem'; |
|
| 28 | + public const CACHE_DELETE_ITEMS = 'CacheDeleteItems'; |
|
| 29 | + public const CACHE_SAVE_ITEM = 'CacheSaveItem'; |
|
| 30 | + public const CACHE_SAVE_MULTIPLE_ITEMS = 'CacheSaveMultipleItems'; |
|
| 31 | + public const CACHE_SAVE_DEFERRED_ITEM = 'CacheSaveDeferredItem'; |
|
| 32 | + public const CACHE_COMMIT_ITEM = 'CacheCommitItem'; |
|
| 33 | + public const CACHE_CLEAR_ITEM = 'CacheClearItem'; |
|
| 34 | + public const CACHE_WRITE_FILE_ON_DISK = 'CacheWriteFileOnDisk'; |
|
| 35 | + public const CACHE_GET_ITEM_IN_SLAM_BATCH = 'CacheGetItemInSlamBatch'; |
|
| 36 | + public const CACHE_REPLICATION_SLAVE_FALLBACK = 'CacheReplicationSlaveFallback'; |
|
| 37 | + public const CACHE_REPLICATION_RANDOM_POOL_CHOSEN = 'CacheReplicationRandomPoolChosen'; |
|
| 38 | + public const CACHE_CLUSTER_BUILT = 'CacheClusterBuilt'; |
|
| 39 | + public const CACHE_ITEM_SET = 'CacheItemSet'; |
|
| 40 | + public const CACHE_ITEM_EXPIRE_AT = 'CacheItemExpireAt'; |
|
| 41 | + public const CACHE_ITEM_EXPIRE_AFTER = 'CacheItemExpireAfter'; |
|
| 42 | + public const CACHE_GET_ALL_ITEMS = 'CacheGetAllItems'; |
|
| 43 | + public const CACHE_DRIVER_CHECKED = 'CacheDriverChecked'; |
|
| 44 | + public const CACHE_DRIVER_CONNECTED = 'CacheDriverConnected'; |
|
| 45 | 45 | |
| 46 | - public static function getEvents(): array |
|
| 47 | - { |
|
| 48 | - return (new \ReflectionClass(static::class))->getConstants(); |
|
| 49 | - } |
|
| 46 | + public static function getEvents(): array |
|
| 47 | + { |
|
| 48 | + return (new \ReflectionClass(static::class))->getConstants(); |
|
| 49 | + } |
|
| 50 | 50 | } |
@@ -54,65 +54,65 @@ |
||
| 54 | 54 | */ |
| 55 | 55 | interface EventManagerInterface |
| 56 | 56 | { |
| 57 | - /** |
|
| 58 | - * @return self |
|
| 59 | - */ |
|
| 60 | - public static function getInstance(): EventManagerInterface; |
|
| 57 | + /** |
|
| 58 | + * @return self |
|
| 59 | + */ |
|
| 60 | + public static function getInstance(): EventManagerInterface; |
|
| 61 | 61 | |
| 62 | - /** |
|
| 63 | - * @param EventManagerInterface $eventManagerInstance |
|
| 64 | - * @return void |
|
| 65 | - */ |
|
| 66 | - public static function setInstance(EventManagerInterface $eventManagerInstance): void; |
|
| 62 | + /** |
|
| 63 | + * @param EventManagerInterface $eventManagerInstance |
|
| 64 | + * @return void |
|
| 65 | + */ |
|
| 66 | + public static function setInstance(EventManagerInterface $eventManagerInstance): void; |
|
| 67 | 67 | |
| 68 | - /** |
|
| 69 | - * @param string $eventName |
|
| 70 | - * @param array<mixed> $args |
|
| 71 | - */ |
|
| 72 | - public function dispatch(string $eventName, ...$args): void; |
|
| 68 | + /** |
|
| 69 | + * @param string $eventName |
|
| 70 | + * @param array<mixed> $args |
|
| 71 | + */ |
|
| 72 | + public function dispatch(string $eventName, ...$args): void; |
|
| 73 | 73 | |
| 74 | - /** |
|
| 75 | - * @param string $name |
|
| 76 | - * @param array<mixed> $arguments |
|
| 77 | - * @throws PhpfastcacheInvalidArgumentException |
|
| 78 | - * @throws BadMethodCallException |
|
| 79 | - */ |
|
| 80 | - public function __call(string $name, array $arguments): void; |
|
| 74 | + /** |
|
| 75 | + * @param string $name |
|
| 76 | + * @param array<mixed> $arguments |
|
| 77 | + * @throws PhpfastcacheInvalidArgumentException |
|
| 78 | + * @throws BadMethodCallException |
|
| 79 | + */ |
|
| 80 | + public function __call(string $name, array $arguments): void; |
|
| 81 | 81 | |
| 82 | - /** |
|
| 83 | - * @param callable $callback |
|
| 84 | - * @param string $callbackName |
|
| 85 | - */ |
|
| 86 | - public function onEveryEvents(callable $callback, string $callbackName): void; |
|
| 82 | + /** |
|
| 83 | + * @param callable $callback |
|
| 84 | + * @param string $callbackName |
|
| 85 | + */ |
|
| 86 | + public function onEveryEvents(callable $callback, string $callbackName): void; |
|
| 87 | 87 | |
| 88 | - /** |
|
| 89 | - * @param string[]|string $events |
|
| 90 | - * @param callable $callback |
|
| 91 | - */ |
|
| 92 | - public function on(array|string $events, callable $callback): void; |
|
| 88 | + /** |
|
| 89 | + * @param string[]|string $events |
|
| 90 | + * @param callable $callback |
|
| 91 | + */ |
|
| 92 | + public function on(array|string $events, callable $callback): void; |
|
| 93 | 93 | |
| 94 | - /** |
|
| 95 | - * @param string $eventName |
|
| 96 | - * @param string $callbackName |
|
| 97 | - * @return bool |
|
| 98 | - */ |
|
| 99 | - public function unbindEventCallback(string $eventName, string $callbackName): bool; |
|
| 94 | + /** |
|
| 95 | + * @param string $eventName |
|
| 96 | + * @param string $callbackName |
|
| 97 | + * @return bool |
|
| 98 | + */ |
|
| 99 | + public function unbindEventCallback(string $eventName, string $callbackName): bool; |
|
| 100 | 100 | |
| 101 | - /** |
|
| 102 | - * @return bool |
|
| 103 | - */ |
|
| 104 | - public function unbindAllEventCallbacks(): bool; |
|
| 101 | + /** |
|
| 102 | + * @return bool |
|
| 103 | + */ |
|
| 104 | + public function unbindAllEventCallbacks(): bool; |
|
| 105 | 105 | |
| 106 | - /** |
|
| 107 | - * @param ExtendedCacheItemPoolInterface $pool |
|
| 108 | - * @return EventManagerInterface |
|
| 109 | - */ |
|
| 110 | - public function getScopedEventManager(ExtendedCacheItemPoolInterface $pool): EventManagerInterface; |
|
| 106 | + /** |
|
| 107 | + * @param ExtendedCacheItemPoolInterface $pool |
|
| 108 | + * @return EventManagerInterface |
|
| 109 | + */ |
|
| 110 | + public function getScopedEventManager(ExtendedCacheItemPoolInterface $pool): EventManagerInterface; |
|
| 111 | 111 | |
| 112 | - /** |
|
| 113 | - * @param ExtendedCacheItemPoolInterface $pool |
|
| 114 | - * @return EventManagerInterface |
|
| 115 | - * @throws PhpfastcacheEventManagerException |
|
| 116 | - */ |
|
| 117 | - public function setItemPoolContext(ExtendedCacheItemPoolInterface $pool): EventManagerInterface; |
|
| 112 | + /** |
|
| 113 | + * @param ExtendedCacheItemPoolInterface $pool |
|
| 114 | + * @return EventManagerInterface |
|
| 115 | + * @throws PhpfastcacheEventManagerException |
|
| 116 | + */ |
|
| 117 | + public function setItemPoolContext(ExtendedCacheItemPoolInterface $pool): EventManagerInterface; |
|
| 118 | 118 | } |
@@ -18,20 +18,20 @@ |
||
| 18 | 18 | |
| 19 | 19 | interface EventManagerDispatcherInterface |
| 20 | 20 | { |
| 21 | - /** |
|
| 22 | - * @return EventManagerInterface |
|
| 23 | - */ |
|
| 24 | - public function getEventManager(): EventManagerInterface; |
|
| 21 | + /** |
|
| 22 | + * @return EventManagerInterface |
|
| 23 | + */ |
|
| 24 | + public function getEventManager(): EventManagerInterface; |
|
| 25 | 25 | |
| 26 | - /** |
|
| 27 | - * @param EventManagerInterface $eventManager |
|
| 28 | - * @return mixed |
|
| 29 | - */ |
|
| 30 | - public function setEventManager(EventManagerInterface $eventManager): static; |
|
| 26 | + /** |
|
| 27 | + * @param EventManagerInterface $eventManager |
|
| 28 | + * @return mixed |
|
| 29 | + */ |
|
| 30 | + public function setEventManager(EventManagerInterface $eventManager): static; |
|
| 31 | 31 | |
| 32 | - /** |
|
| 33 | - * @return bool |
|
| 34 | - * @deprecated Will be removed in v10 |
|
| 35 | - */ |
|
| 36 | - public function hasEventManager(): bool; |
|
| 32 | + /** |
|
| 33 | + * @return bool |
|
| 34 | + * @deprecated Will be removed in v10 |
|
| 35 | + */ |
|
| 36 | + public function hasEventManager(): bool; |
|
| 37 | 37 | } |