From 7b9e62198e93f3b1f76d96821854e62cb4037afa Mon Sep 17 00:00:00 2001
From: Hypolite Petovan <hypolite@mrpetovan.com>
Date: Tue, 15 Mar 2022 10:52:40 -0400
Subject: [PATCH] Suppress a couple MemcachedException

- Replace URL by uri-id in apcontact
- Replace date with a space and nurl by nick and Zulu time in mod/poco
---
 mod/poco.php            | 7 +++++--
 src/Model/APContact.php | 2 +-
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/mod/poco.php b/mod/poco.php
index bd11e0971a..1ccd74b7f1 100644
--- a/mod/poco.php
+++ b/mod/poco.php
@@ -27,6 +27,7 @@ use Friendica\Core\Protocol;
 use Friendica\Core\Renderer;
 use Friendica\Database\DBA;
 use Friendica\DI;
+use Friendica\Util\DateTimeFormat;
 use Friendica\Util\Strings;
 use Friendica\Util\XML;
 
@@ -121,10 +122,12 @@ function poco_init(App $a) {
 			if (isset($contact['account-type'])) {
 				$contact['contact-type'] = $contact['account-type'];
 			}
-			$about = DI::cache()->get("about:" . $contact['updated'] . ":" . $contact['nurl']);
+
+			$cacheKey = 'about:' . $contact['nick'] . ':' . DateTimeFormat::utc($contact['updated'], DateTimeFormat::ATOM);
+			$about = DI::cache()->get($cacheKey);
 			if (is_null($about)) {
 				$about = BBCode::convertForUriId($contact['uri-id'], $contact['about']);
-				DI::cache()->set("about:" . $contact['updated'] . ":" . $contact['nurl'], $about);
+				DI::cache()->set($cacheKey, $about);
 			}
 
 			// Non connected persons can only see the keywords of a Diaspora account
diff --git a/src/Model/APContact.php b/src/Model/APContact.php
index b519655e13..55dd756638 100644
--- a/src/Model/APContact.php
+++ b/src/Model/APContact.php
@@ -168,7 +168,7 @@ class APContact
 
 		// Detect multiple fast repeating request to the same address
 		// See https://github.com/friendica/friendica/issues/9303
-		$cachekey = 'apcontact:getByURL:' . $url;
+		$cachekey = 'apcontact:' . ItemURI::getIdByURI($url);
 		$result = DI::cache()->get($cachekey);
 		if (!is_null($result)) {
 			Logger::notice('Multiple requests for the address', ['url' => $url, 'update' => $update, 'callstack' => System::callstack(20), 'result' => $result]);
-- 
2.39.5