From bf6655a534a6775d30cafa67bd801276bda1d98d Mon Sep 17 00:00:00 2001 From: polo Date: Tue, 13 Aug 2024 23:45:21 +0200 Subject: =?UTF-8?q?VERSION=200.2=20doctrine=20ORM=20et=20entit=C3=A9s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../doctrine/orm/src/Cache/Logging/CacheLogger.php | 60 +++++++ .../orm/src/Cache/Logging/CacheLoggerChain.php | 94 +++++++++++ .../src/Cache/Logging/StatisticsCacheLogger.php | 174 +++++++++++++++++++++ 3 files changed, 328 insertions(+) create mode 100644 vendor/doctrine/orm/src/Cache/Logging/CacheLogger.php create mode 100644 vendor/doctrine/orm/src/Cache/Logging/CacheLoggerChain.php create mode 100644 vendor/doctrine/orm/src/Cache/Logging/StatisticsCacheLogger.php (limited to 'vendor/doctrine/orm/src/Cache/Logging') diff --git a/vendor/doctrine/orm/src/Cache/Logging/CacheLogger.php b/vendor/doctrine/orm/src/Cache/Logging/CacheLogger.php new file mode 100644 index 0000000..64c97c1 --- /dev/null +++ b/vendor/doctrine/orm/src/Cache/Logging/CacheLogger.php @@ -0,0 +1,60 @@ + */ + private array $loggers = []; + + public function setLogger(string $name, CacheLogger $logger): void + { + $this->loggers[$name] = $logger; + } + + public function getLogger(string $name): CacheLogger|null + { + return $this->loggers[$name] ?? null; + } + + /** @return array */ + public function getLoggers(): array + { + return $this->loggers; + } + + public function collectionCacheHit(string $regionName, CollectionCacheKey $key): void + { + foreach ($this->loggers as $logger) { + $logger->collectionCacheHit($regionName, $key); + } + } + + public function collectionCacheMiss(string $regionName, CollectionCacheKey $key): void + { + foreach ($this->loggers as $logger) { + $logger->collectionCacheMiss($regionName, $key); + } + } + + public function collectionCachePut(string $regionName, CollectionCacheKey $key): void + { + foreach ($this->loggers as $logger) { + $logger->collectionCachePut($regionName, $key); + } + } + + public function entityCacheHit(string $regionName, EntityCacheKey $key): void + { + foreach ($this->loggers as $logger) { + $logger->entityCacheHit($regionName, $key); + } + } + + public function entityCacheMiss(string $regionName, EntityCacheKey $key): void + { + foreach ($this->loggers as $logger) { + $logger->entityCacheMiss($regionName, $key); + } + } + + public function entityCachePut(string $regionName, EntityCacheKey $key): void + { + foreach ($this->loggers as $logger) { + $logger->entityCachePut($regionName, $key); + } + } + + public function queryCacheHit(string $regionName, QueryCacheKey $key): void + { + foreach ($this->loggers as $logger) { + $logger->queryCacheHit($regionName, $key); + } + } + + public function queryCacheMiss(string $regionName, QueryCacheKey $key): void + { + foreach ($this->loggers as $logger) { + $logger->queryCacheMiss($regionName, $key); + } + } + + public function queryCachePut(string $regionName, QueryCacheKey $key): void + { + foreach ($this->loggers as $logger) { + $logger->queryCachePut($regionName, $key); + } + } +} diff --git a/vendor/doctrine/orm/src/Cache/Logging/StatisticsCacheLogger.php b/vendor/doctrine/orm/src/Cache/Logging/StatisticsCacheLogger.php new file mode 100644 index 0000000..092104e --- /dev/null +++ b/vendor/doctrine/orm/src/Cache/Logging/StatisticsCacheLogger.php @@ -0,0 +1,174 @@ + */ + private array $cacheMissCountMap = []; + + /** @var array */ + private array $cacheHitCountMap = []; + + /** @var array */ + private array $cachePutCountMap = []; + + public function collectionCacheMiss(string $regionName, CollectionCacheKey $key): void + { + $this->cacheMissCountMap[$regionName] + = ($this->cacheMissCountMap[$regionName] ?? 0) + 1; + } + + public function collectionCacheHit(string $regionName, CollectionCacheKey $key): void + { + $this->cacheHitCountMap[$regionName] + = ($this->cacheHitCountMap[$regionName] ?? 0) + 1; + } + + public function collectionCachePut(string $regionName, CollectionCacheKey $key): void + { + $this->cachePutCountMap[$regionName] + = ($this->cachePutCountMap[$regionName] ?? 0) + 1; + } + + public function entityCacheMiss(string $regionName, EntityCacheKey $key): void + { + $this->cacheMissCountMap[$regionName] + = ($this->cacheMissCountMap[$regionName] ?? 0) + 1; + } + + public function entityCacheHit(string $regionName, EntityCacheKey $key): void + { + $this->cacheHitCountMap[$regionName] + = ($this->cacheHitCountMap[$regionName] ?? 0) + 1; + } + + public function entityCachePut(string $regionName, EntityCacheKey $key): void + { + $this->cachePutCountMap[$regionName] + = ($this->cachePutCountMap[$regionName] ?? 0) + 1; + } + + public function queryCacheHit(string $regionName, QueryCacheKey $key): void + { + $this->cacheHitCountMap[$regionName] + = ($this->cacheHitCountMap[$regionName] ?? 0) + 1; + } + + public function queryCacheMiss(string $regionName, QueryCacheKey $key): void + { + $this->cacheMissCountMap[$regionName] + = ($this->cacheMissCountMap[$regionName] ?? 0) + 1; + } + + public function queryCachePut(string $regionName, QueryCacheKey $key): void + { + $this->cachePutCountMap[$regionName] + = ($this->cachePutCountMap[$regionName] ?? 0) + 1; + } + + /** + * Get the number of entries successfully retrieved from cache. + * + * @param string $regionName The name of the cache region. + */ + public function getRegionHitCount(string $regionName): int + { + return $this->cacheHitCountMap[$regionName] ?? 0; + } + + /** + * Get the number of cached entries *not* found in cache. + * + * @param string $regionName The name of the cache region. + */ + public function getRegionMissCount(string $regionName): int + { + return $this->cacheMissCountMap[$regionName] ?? 0; + } + + /** + * Get the number of cacheable entries put in cache. + * + * @param string $regionName The name of the cache region. + */ + public function getRegionPutCount(string $regionName): int + { + return $this->cachePutCountMap[$regionName] ?? 0; + } + + /** @return array */ + public function getRegionsMiss(): array + { + return $this->cacheMissCountMap; + } + + /** @return array */ + public function getRegionsHit(): array + { + return $this->cacheHitCountMap; + } + + /** @return array */ + public function getRegionsPut(): array + { + return $this->cachePutCountMap; + } + + /** + * Clear region statistics + * + * @param string $regionName The name of the cache region. + */ + public function clearRegionStats(string $regionName): void + { + $this->cachePutCountMap[$regionName] = 0; + $this->cacheHitCountMap[$regionName] = 0; + $this->cacheMissCountMap[$regionName] = 0; + } + + /** + * Clear all statistics + */ + public function clearStats(): void + { + $this->cachePutCountMap = []; + $this->cacheHitCountMap = []; + $this->cacheMissCountMap = []; + } + + /** + * Get the total number of put in cache. + */ + public function getPutCount(): int + { + return array_sum($this->cachePutCountMap); + } + + /** + * Get the total number of entries successfully retrieved from cache. + */ + public function getHitCount(): int + { + return array_sum($this->cacheHitCountMap); + } + + /** + * Get the total number of cached entries *not* found in cache. + */ + public function getMissCount(): int + { + return array_sum($this->cacheMissCountMap); + } +} -- cgit v1.2.3