aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/Memcache/ProfilerWrapperCache.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/private/Memcache/ProfilerWrapperCache.php')
-rw-r--r--lib/private/Memcache/ProfilerWrapperCache.php49
1 files changed, 27 insertions, 22 deletions
diff --git a/lib/private/Memcache/ProfilerWrapperCache.php b/lib/private/Memcache/ProfilerWrapperCache.php
index 8e9b160ba0e..97d9d828a32 100644
--- a/lib/private/Memcache/ProfilerWrapperCache.php
+++ b/lib/private/Memcache/ProfilerWrapperCache.php
@@ -2,25 +2,8 @@
declare(strict_types = 1);
/**
- * @copyright 2022 Carl Schwan <carl@carlschwan.eu>
- *
- * @author Carl Schwan <carl@carlschwan.eu>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OC\Memcache;
@@ -32,9 +15,10 @@ use OCP\IMemcacheTTL;
/**
* Cache wrapper that logs profiling information
+ * @template-implements \ArrayAccess<string,mixed>
*/
class ProfilerWrapperCache extends AbstractDataCollector implements IMemcacheTTL, \ArrayAccess {
- /** @var Redis $wrappedCache*/
+ /** @var Redis $wrappedCache */
protected $wrappedCache;
/** @var string $prefix */
@@ -69,6 +53,7 @@ class ProfilerWrapperCache extends AbstractDataCollector implements IMemcacheTTL
'start' => $start,
'end' => microtime(true),
'op' => $this->getPrefix() . '::get::' . $key,
+ 'hit' => $ret !== null,
];
return $ret;
}
@@ -182,10 +167,30 @@ class ProfilerWrapperCache extends AbstractDataCollector implements IMemcacheTTL
}
/** @inheritDoc */
- public function setTTL($key, $ttl) {
+ public function ncad(string $key, mixed $old): bool {
+ $start = microtime(true);
+ $ret = $this->wrappedCache->ncad($key, $old);
+ $this->data['queries'][] = [
+ 'start' => $start,
+ 'end' => microtime(true),
+ 'op' => $this->getPrefix() . '::ncad::' . $key,
+ ];
+ return $ret;
+ }
+
+ /** @inheritDoc */
+ public function setTTL(string $key, int $ttl) {
$this->wrappedCache->setTTL($key, $ttl);
}
+ public function getTTL(string $key): int|false {
+ return $this->wrappedCache->getTTL($key);
+ }
+
+ public function compareSetTTL(string $key, mixed $value, int $ttl): bool {
+ return $this->wrappedCache->compareSetTTL($key, $value, $ttl);
+ }
+
public function offsetExists($offset): bool {
return $this->hasKey($offset);
}
@@ -206,7 +211,7 @@ class ProfilerWrapperCache extends AbstractDataCollector implements IMemcacheTTL
$this->remove($offset);
}
- public function collect(Request $request, Response $response, \Throwable $exception = null): void {
+ public function collect(Request $request, Response $response, ?\Throwable $exception = null): void {
// Nothing to do here $data is already ready
}