diff options
Diffstat (limited to 'vendor/doctrine/orm/src/Cache/Logging')
3 files changed, 328 insertions, 0 deletions
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 @@ | |||
1 | <?php | ||
2 | |||
3 | declare(strict_types=1); | ||
4 | |||
5 | namespace Doctrine\ORM\Cache\Logging; | ||
6 | |||
7 | use Doctrine\ORM\Cache\CollectionCacheKey; | ||
8 | use Doctrine\ORM\Cache\EntityCacheKey; | ||
9 | use Doctrine\ORM\Cache\QueryCacheKey; | ||
10 | |||
11 | /** | ||
12 | * Interface for logging. | ||
13 | */ | ||
14 | interface CacheLogger | ||
15 | { | ||
16 | /** | ||
17 | * Log an entity put into second level cache. | ||
18 | */ | ||
19 | public function entityCachePut(string $regionName, EntityCacheKey $key): void; | ||
20 | |||
21 | /** | ||
22 | * Log an entity get from second level cache resulted in a hit. | ||
23 | */ | ||
24 | public function entityCacheHit(string $regionName, EntityCacheKey $key): void; | ||
25 | |||
26 | /** | ||
27 | * Log an entity get from second level cache resulted in a miss. | ||
28 | */ | ||
29 | public function entityCacheMiss(string $regionName, EntityCacheKey $key): void; | ||
30 | |||
31 | /** | ||
32 | * Log an entity put into second level cache. | ||
33 | */ | ||
34 | public function collectionCachePut(string $regionName, CollectionCacheKey $key): void; | ||
35 | |||
36 | /** | ||
37 | * Log an entity get from second level cache resulted in a hit. | ||
38 | */ | ||
39 | public function collectionCacheHit(string $regionName, CollectionCacheKey $key): void; | ||
40 | |||
41 | /** | ||
42 | * Log an entity get from second level cache resulted in a miss. | ||
43 | */ | ||
44 | public function collectionCacheMiss(string $regionName, CollectionCacheKey $key): void; | ||
45 | |||
46 | /** | ||
47 | * Log a query put into the query cache. | ||
48 | */ | ||
49 | public function queryCachePut(string $regionName, QueryCacheKey $key): void; | ||
50 | |||
51 | /** | ||
52 | * Log a query get from the query cache resulted in a hit. | ||
53 | */ | ||
54 | public function queryCacheHit(string $regionName, QueryCacheKey $key): void; | ||
55 | |||
56 | /** | ||
57 | * Log a query get from the query cache resulted in a miss. | ||
58 | */ | ||
59 | public function queryCacheMiss(string $regionName, QueryCacheKey $key): void; | ||
60 | } | ||
diff --git a/vendor/doctrine/orm/src/Cache/Logging/CacheLoggerChain.php b/vendor/doctrine/orm/src/Cache/Logging/CacheLoggerChain.php new file mode 100644 index 0000000..8eef3b5 --- /dev/null +++ b/vendor/doctrine/orm/src/Cache/Logging/CacheLoggerChain.php | |||
@@ -0,0 +1,94 @@ | |||
1 | <?php | ||
2 | |||
3 | declare(strict_types=1); | ||
4 | |||
5 | namespace Doctrine\ORM\Cache\Logging; | ||
6 | |||
7 | use Doctrine\ORM\Cache\CollectionCacheKey; | ||
8 | use Doctrine\ORM\Cache\EntityCacheKey; | ||
9 | use Doctrine\ORM\Cache\QueryCacheKey; | ||
10 | |||
11 | class CacheLoggerChain implements CacheLogger | ||
12 | { | ||
13 | /** @var array<string, CacheLogger> */ | ||
14 | private array $loggers = []; | ||
15 | |||
16 | public function setLogger(string $name, CacheLogger $logger): void | ||
17 | { | ||
18 | $this->loggers[$name] = $logger; | ||
19 | } | ||
20 | |||
21 | public function getLogger(string $name): CacheLogger|null | ||
22 | { | ||
23 | return $this->loggers[$name] ?? null; | ||
24 | } | ||
25 | |||
26 | /** @return array<string, CacheLogger> */ | ||
27 | public function getLoggers(): array | ||
28 | { | ||
29 | return $this->loggers; | ||
30 | } | ||
31 | |||
32 | public function collectionCacheHit(string $regionName, CollectionCacheKey $key): void | ||
33 | { | ||
34 | foreach ($this->loggers as $logger) { | ||
35 | $logger->collectionCacheHit($regionName, $key); | ||
36 | } | ||
37 | } | ||
38 | |||
39 | public function collectionCacheMiss(string $regionName, CollectionCacheKey $key): void | ||
40 | { | ||
41 | foreach ($this->loggers as $logger) { | ||
42 | $logger->collectionCacheMiss($regionName, $key); | ||
43 | } | ||
44 | } | ||
45 | |||
46 | public function collectionCachePut(string $regionName, CollectionCacheKey $key): void | ||
47 | { | ||
48 | foreach ($this->loggers as $logger) { | ||
49 | $logger->collectionCachePut($regionName, $key); | ||
50 | } | ||
51 | } | ||
52 | |||
53 | public function entityCacheHit(string $regionName, EntityCacheKey $key): void | ||
54 | { | ||
55 | foreach ($this->loggers as $logger) { | ||
56 | $logger->entityCacheHit($regionName, $key); | ||
57 | } | ||
58 | } | ||
59 | |||
60 | public function entityCacheMiss(string $regionName, EntityCacheKey $key): void | ||
61 | { | ||
62 | foreach ($this->loggers as $logger) { | ||
63 | $logger->entityCacheMiss($regionName, $key); | ||
64 | } | ||
65 | } | ||
66 | |||
67 | public function entityCachePut(string $regionName, EntityCacheKey $key): void | ||
68 | { | ||
69 | foreach ($this->loggers as $logger) { | ||
70 | $logger->entityCachePut($regionName, $key); | ||
71 | } | ||
72 | } | ||
73 | |||
74 | public function queryCacheHit(string $regionName, QueryCacheKey $key): void | ||
75 | { | ||
76 | foreach ($this->loggers as $logger) { | ||
77 | $logger->queryCacheHit($regionName, $key); | ||
78 | } | ||
79 | } | ||
80 | |||
81 | public function queryCacheMiss(string $regionName, QueryCacheKey $key): void | ||
82 | { | ||
83 | foreach ($this->loggers as $logger) { | ||
84 | $logger->queryCacheMiss($regionName, $key); | ||
85 | } | ||
86 | } | ||
87 | |||
88 | public function queryCachePut(string $regionName, QueryCacheKey $key): void | ||
89 | { | ||
90 | foreach ($this->loggers as $logger) { | ||
91 | $logger->queryCachePut($regionName, $key); | ||
92 | } | ||
93 | } | ||
94 | } | ||
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 @@ | |||
1 | <?php | ||
2 | |||
3 | declare(strict_types=1); | ||
4 | |||
5 | namespace Doctrine\ORM\Cache\Logging; | ||
6 | |||
7 | use Doctrine\ORM\Cache\CollectionCacheKey; | ||
8 | use Doctrine\ORM\Cache\EntityCacheKey; | ||
9 | use Doctrine\ORM\Cache\QueryCacheKey; | ||
10 | |||
11 | use function array_sum; | ||
12 | |||
13 | /** | ||
14 | * Provide basic second level cache statistics. | ||
15 | */ | ||
16 | class StatisticsCacheLogger implements CacheLogger | ||
17 | { | ||
18 | /** @var array<string, int> */ | ||
19 | private array $cacheMissCountMap = []; | ||
20 | |||
21 | /** @var array<string, int> */ | ||
22 | private array $cacheHitCountMap = []; | ||
23 | |||
24 | /** @var array<string, int> */ | ||
25 | private array $cachePutCountMap = []; | ||
26 | |||
27 | public function collectionCacheMiss(string $regionName, CollectionCacheKey $key): void | ||
28 | { | ||
29 | $this->cacheMissCountMap[$regionName] | ||
30 | = ($this->cacheMissCountMap[$regionName] ?? 0) + 1; | ||
31 | } | ||
32 | |||
33 | public function collectionCacheHit(string $regionName, CollectionCacheKey $key): void | ||
34 | { | ||
35 | $this->cacheHitCountMap[$regionName] | ||
36 | = ($this->cacheHitCountMap[$regionName] ?? 0) + 1; | ||
37 | } | ||
38 | |||
39 | public function collectionCachePut(string $regionName, CollectionCacheKey $key): void | ||
40 | { | ||
41 | $this->cachePutCountMap[$regionName] | ||
42 | = ($this->cachePutCountMap[$regionName] ?? 0) + 1; | ||
43 | } | ||
44 | |||
45 | public function entityCacheMiss(string $regionName, EntityCacheKey $key): void | ||
46 | { | ||
47 | $this->cacheMissCountMap[$regionName] | ||
48 | = ($this->cacheMissCountMap[$regionName] ?? 0) + 1; | ||
49 | } | ||
50 | |||
51 | public function entityCacheHit(string $regionName, EntityCacheKey $key): void | ||
52 | { | ||
53 | $this->cacheHitCountMap[$regionName] | ||
54 | = ($this->cacheHitCountMap[$regionName] ?? 0) + 1; | ||
55 | } | ||
56 | |||
57 | public function entityCachePut(string $regionName, EntityCacheKey $key): void | ||
58 | { | ||
59 | $this->cachePutCountMap[$regionName] | ||
60 | = ($this->cachePutCountMap[$regionName] ?? 0) + 1; | ||
61 | } | ||
62 | |||
63 | public function queryCacheHit(string $regionName, QueryCacheKey $key): void | ||
64 | { | ||
65 | $this->cacheHitCountMap[$regionName] | ||
66 | = ($this->cacheHitCountMap[$regionName] ?? 0) + 1; | ||
67 | } | ||
68 | |||
69 | public function queryCacheMiss(string $regionName, QueryCacheKey $key): void | ||
70 | { | ||
71 | $this->cacheMissCountMap[$regionName] | ||
72 | = ($this->cacheMissCountMap[$regionName] ?? 0) + 1; | ||
73 | } | ||
74 | |||
75 | public function queryCachePut(string $regionName, QueryCacheKey $key): void | ||
76 | { | ||
77 | $this->cachePutCountMap[$regionName] | ||
78 | = ($this->cachePutCountMap[$regionName] ?? 0) + 1; | ||
79 | } | ||
80 | |||
81 | /** | ||
82 | * Get the number of entries successfully retrieved from cache. | ||
83 | * | ||
84 | * @param string $regionName The name of the cache region. | ||
85 | */ | ||
86 | public function getRegionHitCount(string $regionName): int | ||
87 | { | ||
88 | return $this->cacheHitCountMap[$regionName] ?? 0; | ||
89 | } | ||
90 | |||
91 | /** | ||
92 | * Get the number of cached entries *not* found in cache. | ||
93 | * | ||
94 | * @param string $regionName The name of the cache region. | ||
95 | */ | ||
96 | public function getRegionMissCount(string $regionName): int | ||
97 | { | ||
98 | return $this->cacheMissCountMap[$regionName] ?? 0; | ||
99 | } | ||
100 | |||
101 | /** | ||
102 | * Get the number of cacheable entries put in cache. | ||
103 | * | ||
104 | * @param string $regionName The name of the cache region. | ||
105 | */ | ||
106 | public function getRegionPutCount(string $regionName): int | ||
107 | { | ||
108 | return $this->cachePutCountMap[$regionName] ?? 0; | ||
109 | } | ||
110 | |||
111 | /** @return array<string, int> */ | ||
112 | public function getRegionsMiss(): array | ||
113 | { | ||
114 | return $this->cacheMissCountMap; | ||
115 | } | ||
116 | |||
117 | /** @return array<string, int> */ | ||
118 | public function getRegionsHit(): array | ||
119 | { | ||
120 | return $this->cacheHitCountMap; | ||
121 | } | ||
122 | |||
123 | /** @return array<string, int> */ | ||
124 | public function getRegionsPut(): array | ||
125 | { | ||
126 | return $this->cachePutCountMap; | ||
127 | } | ||
128 | |||
129 | /** | ||
130 | * Clear region statistics | ||
131 | * | ||
132 | * @param string $regionName The name of the cache region. | ||
133 | */ | ||
134 | public function clearRegionStats(string $regionName): void | ||
135 | { | ||
136 | $this->cachePutCountMap[$regionName] = 0; | ||
137 | $this->cacheHitCountMap[$regionName] = 0; | ||
138 | $this->cacheMissCountMap[$regionName] = 0; | ||
139 | } | ||
140 | |||
141 | /** | ||
142 | * Clear all statistics | ||
143 | */ | ||
144 | public function clearStats(): void | ||
145 | { | ||
146 | $this->cachePutCountMap = []; | ||
147 | $this->cacheHitCountMap = []; | ||
148 | $this->cacheMissCountMap = []; | ||
149 | } | ||
150 | |||
151 | /** | ||
152 | * Get the total number of put in cache. | ||
153 | */ | ||
154 | public function getPutCount(): int | ||
155 | { | ||
156 | return array_sum($this->cachePutCountMap); | ||
157 | } | ||
158 | |||
159 | /** | ||
160 | * Get the total number of entries successfully retrieved from cache. | ||
161 | */ | ||
162 | public function getHitCount(): int | ||
163 | { | ||
164 | return array_sum($this->cacheHitCountMap); | ||
165 | } | ||
166 | |||
167 | /** | ||
168 | * Get the total number of cached entries *not* found in cache. | ||
169 | */ | ||
170 | public function getMissCount(): int | ||
171 | { | ||
172 | return array_sum($this->cacheMissCountMap); | ||
173 | } | ||
174 | } | ||