diff --git a/mod/ping.php b/mod/ping.php index c76780f697..9593d6ed26 100644 --- a/mod/ping.php +++ b/mod/ping.php @@ -208,7 +208,7 @@ function ping_init(App $a) DBA::escape(DateTimeFormat::utcNow()) ); if (DBA::isResult($ev)) { - Cache::set($cachekey, $ev, Cache::HOUR); + DI::cache()->set($cachekey, $ev, Cache::HOUR); } } diff --git a/mod/poco.php b/mod/poco.php index 2ed871285b..cbee264585 100644 --- a/mod/poco.php +++ b/mod/poco.php @@ -13,6 +13,7 @@ use Friendica\Core\Protocol; use Friendica\Core\Renderer; use Friendica\Core\System; use Friendica\Database\DBA; +use Friendica\DI; use Friendica\Protocol\PortableContact; use Friendica\Util\DateTimeFormat; use Friendica\Util\Strings; @@ -258,7 +259,7 @@ function poco_init(App $a) { $about = Cache::get("about:" . $contact['updated'] . ":" . $contact['nurl']); if (is_null($about)) { $about = BBCode::convert($contact['about'], false); - Cache::set("about:" . $contact['updated'] . ":" . $contact['nurl'], $about); + DI::cache()->set("about:" . $contact['updated'] . ":" . $contact['nurl'], $about); } // Non connected persons can only see the keywords of a Diaspora account diff --git a/src/Content/OEmbed.php b/src/Content/OEmbed.php index 95fd6530b6..51918283e0 100644 --- a/src/Content/OEmbed.php +++ b/src/Content/OEmbed.php @@ -125,7 +125,7 @@ class OEmbed $cache_ttl = Cache::FIVE_MINUTES; } - Cache::set($cache_key, $json_string, $cache_ttl); + DI::cache()->set($cache_key, $json_string, $cache_ttl); } if ($oembed->type == 'error') { diff --git a/src/Content/Text/BBCode.php b/src/Content/Text/BBCode.php index 51fa08ad3d..1489ed232f 100644 --- a/src/Content/Text/BBCode.php +++ b/src/Content/Text/BBCode.php @@ -1112,7 +1112,7 @@ class BBCode } } } - Cache::set($cache_key, $text); + DI::cache()->set($cache_key, $text); } return $text; @@ -1194,7 +1194,7 @@ class BBCode } } } - Cache::set($cache_key, $text); + DI::cache()->set($cache_key, $text); return $text; } diff --git a/src/Core/Cache.php b/src/Core/Cache.php index 0328cf84cb..410f9fea18 100644 --- a/src/Core/Cache.php +++ b/src/Core/Cache.php @@ -43,21 +43,4 @@ class Cache { return DI::cache()->get($key); } - - /** - * @brief Put data in the cache according to the key - * - * The input $value can have multiple formats. - * - * @param string $key The key to the cached data - * @param mixed $value The value that is about to be stored - * @param integer $duration The cache lifespan - * - * @return bool - * @throws \Exception - */ - public static function set($key, $value, $duration = CacheClass::MONTH) - { - return DI::cache()->set($key, $value, $duration); - } } diff --git a/src/Model/Photo.php b/src/Model/Photo.php index c4dbf2b30a..0d05d81d0d 100644 --- a/src/Model/Photo.php +++ b/src/Model/Photo.php @@ -569,7 +569,7 @@ class Photo DBA::escape(L10n::t("Contact Photos")) ); } - Cache::set($key, $albums, Cache::DAY); + DI::cache()->set($key, $albums, Cache::DAY); } return $albums; } @@ -582,7 +582,7 @@ class Photo public static function clearAlbumCache($uid) { $key = "photo_albums:".$uid.":".local_user().":".remote_user(); - Cache::set($key, null, Cache::DAY); + DI::cache()->set($key, null, Cache::DAY); } /** diff --git a/src/Model/Profile.php b/src/Model/Profile.php index d7cc906fdb..a5619c999b 100644 --- a/src/Model/Profile.php +++ b/src/Model/Profile.php @@ -608,7 +608,7 @@ class Profile ); if (DBA::isResult($s)) { $r = DBA::toArray($s); - Cache::set($cachekey, $r, Cache::HOUR); + DI::cache()->set($cachekey, $r, Cache::HOUR); } } @@ -1070,7 +1070,7 @@ class Profile Logger::log('URL ' . $my_url . ' already tried to authenticate.', Logger::DEBUG); return; } else { - Cache::set($cachekey, true, Cache::MINUTE); + DI::cache()->set($cachekey, true, Cache::MINUTE); } Logger::log('Not authenticated. Invoking reverse magic-auth for ' . $my_url, Logger::DEBUG); diff --git a/src/Model/Term.php b/src/Model/Term.php index 08a02ff075..4eca9639ff 100644 --- a/src/Model/Term.php +++ b/src/Model/Term.php @@ -84,7 +84,7 @@ class Term if (DBA::isResult($tagsStmt)) { $tags = DBA::toArray($tagsStmt); - Cache::set('global_trending_tags', $tags, Cache::HOUR); + DI::cache()->set('global_trending_tags', $tags, Cache::HOUR); } } @@ -129,7 +129,7 @@ class Term if (DBA::isResult($tagsStmt)) { $tags = DBA::toArray($tagsStmt); - Cache::set('local_trending_tags', $tags, Cache::HOUR); + DI::cache()->set('local_trending_tags', $tags, Cache::HOUR); } } diff --git a/src/Module/Search/Index.php b/src/Module/Search/Index.php index 247ac5988c..776b3fced9 100644 --- a/src/Module/Search/Index.php +++ b/src/Module/Search/Index.php @@ -59,9 +59,9 @@ class Index extends BaseSearchModule if (($resultdata->time > (time() - $crawl_permit_period)) && ($resultdata->accesses > $free_crawls)) { throw new HTTPException\TooManyRequestsException(L10n::t('Only one search per minute is permitted for not logged in users.')); } - Cache::set('remote_search:' . $remote, json_encode(['time' => time(), 'accesses' => $resultdata->accesses + 1]), CacheClass::HOUR); + DI::cache()->set('remote_search:' . $remote, json_encode(['time' => time(), 'accesses' => $resultdata->accesses + 1]), CacheClass::HOUR); } else { - Cache::set('remote_search:' . $remote, json_encode(['time' => time(), 'accesses' => 1]), CacheClass::HOUR); + DI::cache()->set('remote_search:' . $remote, json_encode(['time' => time(), 'accesses' => 1]), CacheClass::HOUR); } } diff --git a/src/Network/Probe.php b/src/Network/Probe.php index 122df70ce7..c3279cd9d2 100644 --- a/src/Network/Probe.php +++ b/src/Network/Probe.php @@ -409,7 +409,7 @@ class Probe // Only store into the cache if the value seems to be valid if (!in_array($data['network'], [Protocol::PHANTOM, Protocol::MAIL])) { - Cache::set('Probe::uri:' . $network . ':' . $uri, $data, Cache::DAY); + DI::cache()->set('Probe::uri:' . $network . ':' . $uri, $data, Cache::DAY); } return $data; diff --git a/src/Protocol/ActivityPub/Transmitter.php b/src/Protocol/ActivityPub/Transmitter.php index 6a512323cf..9a2b584fe3 100644 --- a/src/Protocol/ActivityPub/Transmitter.php +++ b/src/Protocol/ActivityPub/Transmitter.php @@ -827,7 +827,7 @@ class Transmitter $data = ActivityPub\Transmitter::createActivityFromItem($item_id); - Cache::set($cachekey, $data, Cache::QUARTER_HOUR); + DI::cache()->set($cachekey, $data, Cache::QUARTER_HOUR); return $data; } diff --git a/src/Protocol/Diaspora.php b/src/Protocol/Diaspora.php index a683a23514..2d94e96c22 100644 --- a/src/Protocol/Diaspora.php +++ b/src/Protocol/Diaspora.php @@ -3272,7 +3272,7 @@ class Diaspora Logger::log("Send participation for ".$item["guid"]." by ".$author, Logger::DEBUG); // It doesn't matter what we store, we only want to avoid sending repeated notifications for the same item - Cache::set($cachekey, $item["guid"], Cache::QUARTER_HOUR); + DI::cache()->set($cachekey, $item["guid"], Cache::QUARTER_HOUR); return self::buildAndTransmit($owner, $contact, "participation", $message); } @@ -3628,7 +3628,7 @@ class Diaspora $msg = ["type" => $type, "message" => $message]; - Cache::set($cachekey, $msg, Cache::QUARTER_HOUR); + DI::cache()->set($cachekey, $msg, Cache::QUARTER_HOUR); return $msg; } @@ -3798,7 +3798,7 @@ class Diaspora $comment['thread_parent_guid'] = $thread_parent_item['guid']; } - Cache::set($cachekey, $comment, Cache::QUARTER_HOUR); + DI::cache()->set($cachekey, $comment, Cache::QUARTER_HOUR); return($comment); } diff --git a/src/Protocol/OStatus.php b/src/Protocol/OStatus.php index 21659a6036..38936762e0 100644 --- a/src/Protocol/OStatus.php +++ b/src/Protocol/OStatus.php @@ -2246,7 +2246,7 @@ class OStatus $feeddata = trim($doc->saveXML()); $msg = ['feed' => $feeddata, 'last_update' => $last_update]; - Cache::set($cachekey, $msg, Cache::QUARTER_HOUR); + DI::cache()->set($cachekey, $msg, Cache::QUARTER_HOUR); Logger::log('Feed duration: ' . number_format(microtime(true) - $stamp, 3) . ' - ' . $owner_nick . ' - ' . $filter . ' - ' . $previous_created, Logger::DEBUG); diff --git a/src/Util/Images.php b/src/Util/Images.php index e19304bba1..b557d891d8 100644 --- a/src/Util/Images.php +++ b/src/Util/Images.php @@ -130,7 +130,7 @@ class Images if (empty($data) || !is_array($data)) { $data = self::getInfoFromURL($url); - Cache::set($url, $data); + DI::cache()->set($url, $data); } return $data; diff --git a/src/Util/JsonLD.php b/src/Util/JsonLD.php index 926fa1437d..598898c0e8 100644 --- a/src/Util/JsonLD.php +++ b/src/Util/JsonLD.php @@ -7,6 +7,7 @@ namespace Friendica\Util; use Friendica\Core\Cache; use Friendica\Core\Logger; use Exception; +use Friendica\DI; /** * @brief This class contain methods to work with JsonLD data @@ -45,7 +46,7 @@ class JsonLD } $data = jsonld_default_document_loader($url); - Cache::set('documentLoader:' . $url, $data, Cache::DAY); + DI::cache()->set('documentLoader:' . $url, $data, Cache::DAY); return $data; } diff --git a/src/Worker/SearchDirectory.php b/src/Worker/SearchDirectory.php index 4503f21ca6..fcac721dfd 100644 --- a/src/Worker/SearchDirectory.php +++ b/src/Worker/SearchDirectory.php @@ -10,6 +10,7 @@ use Friendica\Core\Logger; use Friendica\Core\Protocol; use Friendica\Core\Search; use Friendica\Database\DBA; +use Friendica\DI; use Friendica\Model\GContact; use Friendica\Model\GServer; use Friendica\Network\Probe; @@ -80,6 +81,6 @@ class SearchDirectory } } } - Cache::set('SearchDirectory:' . $search, time(), Cache::DAY); + DI::cache()->set('SearchDirectory:' . $search, time(), Cache::DAY); } }