From: Michael Date: Tue, 17 May 2022 15:39:04 +0000 (+0000) Subject: Caching of "noscrape" X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=0b50dc363bc5db93f96c22fc6a5546b17d0bdb79;p=friendica.git Caching of "noscrape" --- diff --git a/src/Model/Contact.php b/src/Model/Contact.php index eeaf5f81df..bf1a50cbc4 100644 --- a/src/Model/Contact.php +++ b/src/Model/Contact.php @@ -35,6 +35,7 @@ use Friendica\Core\Worker; use Friendica\Database\Database; use Friendica\Database\DBA; use Friendica\DI; +use Friendica\Module\NoScrape; use Friendica\Network\HTTPException; use Friendica\Network\Probe; use Friendica\Protocol\Activity; @@ -909,6 +910,7 @@ class Contact DI::cache()->delete(ActivityPub\Transmitter::CACHEKEY_CONTACTS . 'followers:' . $uid); DI::cache()->delete(ActivityPub\Transmitter::CACHEKEY_CONTACTS . 'following:' . $uid); + DI::cache()->delete(NoScrape::CACHEKEY . $uid); } /** diff --git a/src/Module/NoScrape.php b/src/Module/NoScrape.php index c315ff0454..fbc01c2d3c 100644 --- a/src/Module/NoScrape.php +++ b/src/Module/NoScrape.php @@ -22,6 +22,7 @@ namespace Friendica\Module; use Friendica\BaseModule; +use Friendica\Core\Cache\Enum\Duration; use Friendica\Core\Protocol; use Friendica\Core\System; use Friendica\Database\DBA; @@ -35,6 +36,8 @@ use Friendica\Model\User; */ class NoScrape extends BaseModule { + const CACHEKEY = 'noscrape:'; + protected function rawContent(array $request = []) { $a = DI::app(); @@ -55,6 +58,12 @@ class NoScrape extends BaseModule System::jsonError(404, 'Profile not found'); } + $cachekey = self::CACHEKEY . $owner['uid']; + $result = DI::cache()->get($cachekey); + if (!is_null($result)) { + System::jsonExit($result); + } + $json_info = [ 'addr' => $owner['addr'], 'nick' => $which, @@ -126,6 +135,8 @@ class NoScrape extends BaseModule } } + DI::cache()->set($cachekey, $json_info, Duration::DAY); + System::jsonExit($json_info); } }