From f0499e72695e716614beb3c3dd454f6c968a6b64 Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 28 Jul 2022 20:25:38 +0000 Subject: [PATCH] Use negative caching --- src/Protocol/ActivityPub/Processor.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Protocol/ActivityPub/Processor.php b/src/Protocol/ActivityPub/Processor.php index bfff5f84b..3b31e6d3c 100644 --- a/src/Protocol/ActivityPub/Processor.php +++ b/src/Protocol/ActivityPub/Processor.php @@ -1207,13 +1207,19 @@ class Processor $object = DI::cache()->get($cachekey); if (!is_null($object)) { - Logger::debug('Fetch from cache', ['url' => $url, 'uid' => $uid]); + if (!empty($object)) { + Logger::debug('Fetch from cache', ['url' => $url, 'uid' => $uid]); + } else { + Logger::debug('Fetch from negative cache', ['url' => $url, 'uid' => $uid]); + } return $object; } $object = ActivityPub::fetchContent($url, $uid); if (empty($object)) { Logger::notice('Activity was not fetchable, aborting.', ['url' => $url, 'uid' => $uid]); + // We perform negative caching. + DI::cache()->set($cachekey, [], Duration::FIVE_MINUTES); return []; }