From f7ca437ba685878e410779c64a6a6f476b6381cd Mon Sep 17 00:00:00 2001 From: nupplaPhil Date: Tue, 7 Jan 2020 00:34:26 +0100 Subject: [PATCH 1/6] Remove unused method Cache::getAllKeys() --- src/Core/Cache.php | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/src/Core/Cache.php b/src/Core/Cache.php index d0a04b9ec..15e5deba2 100644 --- a/src/Core/Cache.php +++ b/src/Core/Cache.php @@ -31,19 +31,6 @@ class Cache /** @deprecated Use CacheClass::INFINITE */ const INFINITE = CacheClass::INFINITE; - /** - * @brief Returns all the cache keys sorted alphabetically - * - * @param string $prefix Prefix of the keys (optional) - * - * @return array Empty if the driver doesn't support this feature - * @throws \Exception - */ - public static function getAllKeys($prefix = null) - { - return DI::cache()->getAllKeys($prefix); - } - /** * @brief Fetch cached data according to the key * From 182f390520f3eda0207c2d74fd098ae1f2b0086d Mon Sep 17 00:00:00 2001 From: nupplaPhil Date: Tue, 7 Jan 2020 00:35:03 +0100 Subject: [PATCH 2/6] Move Cache::clear() to DI::cache()->clear() --- src/Core/Cache.php | 13 ------------- src/Worker/CronJobs.php | 2 +- 2 files changed, 1 insertion(+), 14 deletions(-) diff --git a/src/Core/Cache.php b/src/Core/Cache.php index 15e5deba2..3e8a3f004 100644 --- a/src/Core/Cache.php +++ b/src/Core/Cache.php @@ -73,17 +73,4 @@ class Cache { return DI::cache()->delete($key); } - - /** - * @brief Remove outdated data from the cache - * - * @param boolean $outdated just remove outdated values - * - * @return bool - * @throws \Exception - */ - public static function clear($outdated = true) - { - return DI::cache()->clear($outdated); - } } diff --git a/src/Worker/CronJobs.php b/src/Worker/CronJobs.php index 6267bf6f3..e88949e65 100644 --- a/src/Worker/CronJobs.php +++ b/src/Worker/CronJobs.php @@ -154,7 +154,7 @@ class CronJobs } // clear old cache - Cache::clear(); + DI::cache()->clear(); // clear old item cache files clear_cache(); From 3369dfaad9d3e36235962f8c5aef4a461a4bd6d0 Mon Sep 17 00:00:00 2001 From: nupplaPhil Date: Tue, 7 Jan 2020 00:37:01 +0100 Subject: [PATCH 3/6] Remove unused function Cache::delete() --- src/Core/Cache.php | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/src/Core/Cache.php b/src/Core/Cache.php index 3e8a3f004..0328cf84c 100644 --- a/src/Core/Cache.php +++ b/src/Core/Cache.php @@ -60,17 +60,4 @@ class Cache { return DI::cache()->set($key, $value, $duration); } - - /** - * @brief Delete a value from the cache - * - * @param string $key The key to the cached data - * - * @return bool - * @throws \Exception - */ - public static function delete($key) - { - return DI::cache()->delete($key); - } } From f68929633b4eb04290381d269e80856fb65c4c5f Mon Sep 17 00:00:00 2001 From: nupplaPhil Date: Tue, 7 Jan 2020 00:41:20 +0100 Subject: [PATCH 4/6] Move Cache::set() to DI::cache()->set() --- mod/ping.php | 2 +- mod/poco.php | 3 ++- src/Content/OEmbed.php | 2 +- src/Content/Text/BBCode.php | 4 ++-- src/Core/Cache.php | 17 ----------------- src/Model/Photo.php | 4 ++-- src/Model/Profile.php | 4 ++-- src/Model/Term.php | 4 ++-- src/Module/Search/Index.php | 4 ++-- src/Network/Probe.php | 2 +- src/Protocol/ActivityPub/Transmitter.php | 2 +- src/Protocol/Diaspora.php | 6 +++--- src/Protocol/OStatus.php | 2 +- src/Util/Images.php | 2 +- src/Util/JsonLD.php | 3 ++- src/Worker/SearchDirectory.php | 3 ++- 16 files changed, 25 insertions(+), 39 deletions(-) diff --git a/mod/ping.php b/mod/ping.php index c76780f69..9593d6ed2 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 2ed871285..cbee26458 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 95fd6530b..51918283e 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 51fa08ad3..1489ed232 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 0328cf84c..410f9fea1 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 c4dbf2b30..0d05d81d0 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 d7cc906fd..a5619c999 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 08a02ff07..4eca9639f 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 247ac5988..776b3fced 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 122df70ce..c3279cd9d 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 6a512323c..9a2b584fe 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 a683a2351..2d94e96c2 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 21659a603..38936762e 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 e19304bba..b557d891d 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 926fa1437..598898c0e 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 4503f21ca..fcac721df 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); } } From fe078410a1cfa2b81a5f69158876a78d6c23d9cb Mon Sep 17 00:00:00 2001 From: nupplaPhil Date: Tue, 7 Jan 2020 00:45:49 +0100 Subject: [PATCH 5/6] Move Cache::get() to DI::cache()->get() --- mod/ping.php | 2 +- mod/poco.php | 2 +- src/Content/OEmbed.php | 2 +- src/Content/Text/BBCode.php | 4 ++-- src/Core/Cache.php | 13 ------------- src/Model/Photo.php | 2 +- src/Model/Profile.php | 4 ++-- src/Model/Term.php | 4 ++-- src/Module/Search/Index.php | 2 +- src/Network/Probe.php | 2 +- src/Protocol/ActivityPub/Transmitter.php | 2 +- src/Protocol/Diaspora.php | 6 +++--- src/Protocol/OStatus.php | 2 +- src/Util/Images.php | 2 +- src/Util/JsonLD.php | 2 +- src/Worker/SearchDirectory.php | 2 +- 16 files changed, 20 insertions(+), 33 deletions(-) diff --git a/mod/ping.php b/mod/ping.php index 9593d6ed2..d00d0988a 100644 --- a/mod/ping.php +++ b/mod/ping.php @@ -197,7 +197,7 @@ function ping_init(App $a) } $cachekey = "ping_init:".local_user(); - $ev = Cache::get($cachekey); + $ev = DI::cache()->get($cachekey); if (is_null($ev)) { $ev = q( "SELECT type, start, adjust FROM `event` diff --git a/mod/poco.php b/mod/poco.php index cbee26458..b21dbf313 100644 --- a/mod/poco.php +++ b/mod/poco.php @@ -256,7 +256,7 @@ function poco_init(App $a) { if (isset($contact['account-type'])) { $contact['contact-type'] = $contact['account-type']; } - $about = Cache::get("about:" . $contact['updated'] . ":" . $contact['nurl']); + $about = DI::cache()->get("about:" . $contact['updated'] . ":" . $contact['nurl']); if (is_null($about)) { $about = BBCode::convert($contact['about'], false); DI::cache()->set("about:" . $contact['updated'] . ":" . $contact['nurl'], $about); diff --git a/src/Content/OEmbed.php b/src/Content/OEmbed.php index 51918283e..6c62d6cfd 100644 --- a/src/Content/OEmbed.php +++ b/src/Content/OEmbed.php @@ -66,7 +66,7 @@ class OEmbed if (DBA::isResult($oembed_record)) { $json_string = $oembed_record['content']; } else { - $json_string = Cache::get($cache_key); + $json_string = DI::cache()->get($cache_key); } // These media files should now be caught in bbcode.php diff --git a/src/Content/Text/BBCode.php b/src/Content/Text/BBCode.php index 1489ed232..63e9c55dc 100644 --- a/src/Content/Text/BBCode.php +++ b/src/Content/Text/BBCode.php @@ -1070,7 +1070,7 @@ class BBCode private static function removePictureLinksCallback($match) { $cache_key = 'remove:' . $match[1]; - $text = Cache::get($cache_key); + $text = DI::cache()->get($cache_key); if (is_null($text)) { $a = DI::app(); @@ -1143,7 +1143,7 @@ class BBCode } $cache_key = 'clean:' . $match[1]; - $text = Cache::get($cache_key); + $text = DI::cache()->get($cache_key); if (!is_null($text)) { return $text; } diff --git a/src/Core/Cache.php b/src/Core/Cache.php index 410f9fea1..4d5d8f087 100644 --- a/src/Core/Cache.php +++ b/src/Core/Cache.php @@ -30,17 +30,4 @@ class Cache const MINUTE = CacheClass::MINUTE; /** @deprecated Use CacheClass::INFINITE */ const INFINITE = CacheClass::INFINITE; - - /** - * @brief Fetch cached data according to the key - * - * @param string $key The key to the cached data - * - * @return mixed Cached $value or "null" if not found - * @throws \Exception - */ - public static function get($key) - { - return DI::cache()->get($key); - } } diff --git a/src/Model/Photo.php b/src/Model/Photo.php index 0d05d81d0..df4d50dd3 100644 --- a/src/Model/Photo.php +++ b/src/Model/Photo.php @@ -546,7 +546,7 @@ class Photo $sql_extra = Security::getPermissionsSQLByUserId($uid); $key = "photo_albums:".$uid.":".local_user().":".remote_user(); - $albums = Cache::get($key); + $albums = DI::cache()->get($key); if (is_null($albums) || $update) { if (!Config::get("system", "no_count", false)) { /// @todo This query needs to be renewed. It is really slow diff --git a/src/Model/Profile.php b/src/Model/Profile.php index a5619c999..f9bb5d27a 100644 --- a/src/Model/Profile.php +++ b/src/Model/Profile.php @@ -586,7 +586,7 @@ class Profile $bd_short = L10n::t('F d'); $cachekey = 'get_birthdays:' . local_user(); - $r = Cache::get($cachekey); + $r = DI::cache()->get($cachekey); if (is_null($r)) { $s = DBA::p( "SELECT `event`.*, `event`.`id` AS `eid`, `contact`.* FROM `event` @@ -1066,7 +1066,7 @@ class Profile // Avoid endless loops $cachekey = 'zrlInit:' . $my_url; - if (Cache::get($cachekey)) { + if (DI::cache()->get($cachekey)) { Logger::log('URL ' . $my_url . ' already tried to authenticate.', Logger::DEBUG); return; } else { diff --git a/src/Model/Term.php b/src/Model/Term.php index 4eca9639f..077df7386 100644 --- a/src/Model/Term.php +++ b/src/Model/Term.php @@ -57,7 +57,7 @@ class Term */ public static function getGlobalTrendingHashtags(int $period, $limit = 10) { - $tags = Cache::get('global_trending_tags'); + $tags = DI::cache()->get('global_trending_tags'); if (!$tags) { $tagsStmt = DBA::p("SELECT t.`term`, COUNT(*) AS `score` @@ -100,7 +100,7 @@ class Term */ public static function getLocalTrendingHashtags(int $period, $limit = 10) { - $tags = Cache::get('local_trending_tags'); + $tags = DI::cache()->get('local_trending_tags'); if (!$tags) { $tagsStmt = DBA::p("SELECT t.`term`, COUNT(*) AS `score` diff --git a/src/Module/Search/Index.php b/src/Module/Search/Index.php index 776b3fced..3cf06ede7 100644 --- a/src/Module/Search/Index.php +++ b/src/Module/Search/Index.php @@ -53,7 +53,7 @@ class Index extends BaseSearchModule $crawl_permit_period = 10; $remote = $_SERVER['REMOTE_ADDR']; - $result = Cache::get('remote_search:' . $remote); + $result = DI::cache()->get('remote_search:' . $remote); if (!is_null($result)) { $resultdata = json_decode($result); if (($resultdata->time > (time() - $crawl_permit_period)) && ($resultdata->accesses > $free_crawls)) { diff --git a/src/Network/Probe.php b/src/Network/Probe.php index c3279cd9d..051607710 100644 --- a/src/Network/Probe.php +++ b/src/Network/Probe.php @@ -332,7 +332,7 @@ class Probe public static function uri($uri, $network = '', $uid = -1, $cache = true) { if ($cache) { - $result = Cache::get('Probe::uri:' . $network . ':' . $uri); + $result = DI::cache()->get('Probe::uri:' . $network . ':' . $uri); if (!is_null($result)) { return $result; } diff --git a/src/Protocol/ActivityPub/Transmitter.php b/src/Protocol/ActivityPub/Transmitter.php index 9a2b584fe..144ce9731 100644 --- a/src/Protocol/ActivityPub/Transmitter.php +++ b/src/Protocol/ActivityPub/Transmitter.php @@ -819,7 +819,7 @@ class Transmitter $cachekey = 'APDelivery:createActivity:' . $item_id; if (!$force) { - $data = Cache::get($cachekey); + $data = DI::cache()->get($cachekey); if (!is_null($data)) { return $data; } diff --git a/src/Protocol/Diaspora.php b/src/Protocol/Diaspora.php index 2d94e96c2..db3c80f49 100644 --- a/src/Protocol/Diaspora.php +++ b/src/Protocol/Diaspora.php @@ -3246,7 +3246,7 @@ class Diaspora $cachekey = "diaspora:sendParticipation:".$item['guid']; - $result = Cache::get($cachekey); + $result = DI::cache()->get($cachekey); if (!is_null($result)) { return; } @@ -3524,7 +3524,7 @@ class Diaspora { $cachekey = "diaspora:buildStatus:".$item['guid']; - $result = Cache::get($cachekey); + $result = DI::cache()->get($cachekey); if (!is_null($result)) { return $result; } @@ -3749,7 +3749,7 @@ class Diaspora { $cachekey = "diaspora:constructComment:".$item['guid']; - $result = Cache::get($cachekey); + $result = DI::cache()->get($cachekey); if (!is_null($result)) { return $result; } diff --git a/src/Protocol/OStatus.php b/src/Protocol/OStatus.php index 38936762e..04d349be0 100644 --- a/src/Protocol/OStatus.php +++ b/src/Protocol/OStatus.php @@ -2185,7 +2185,7 @@ class OStatus // Don't cache when the last item was posted less then 15 minutes ago (Cache duration) if ((time() - strtotime($owner['last-item'])) < 15*60) { - $result = Cache::get($cachekey); + $result = DI::cache()->get($cachekey); if (!$nocache && !is_null($result)) { Logger::log('Feed duration: ' . number_format(microtime(true) - $stamp, 3) . ' - ' . $owner_nick . ' - ' . $filter . ' - ' . $previous_created . ' (cached)', Logger::DEBUG); $last_update = $result['last_update']; diff --git a/src/Util/Images.php b/src/Util/Images.php index b557d891d..011868944 100644 --- a/src/Util/Images.php +++ b/src/Util/Images.php @@ -125,7 +125,7 @@ class Images return $data; } - $data = Cache::get($url); + $data = DI::cache()->get($url); if (empty($data) || !is_array($data)) { $data = self::getInfoFromURL($url); diff --git a/src/Util/JsonLD.php b/src/Util/JsonLD.php index 598898c0e..4a5836068 100644 --- a/src/Util/JsonLD.php +++ b/src/Util/JsonLD.php @@ -40,7 +40,7 @@ class JsonLD exit(); } - $result = Cache::get('documentLoader:' . $url); + $result = DI::cache()->get('documentLoader:' . $url); if (!is_null($result)) { return $result; } diff --git a/src/Worker/SearchDirectory.php b/src/Worker/SearchDirectory.php index fcac721df..4d3087a70 100644 --- a/src/Worker/SearchDirectory.php +++ b/src/Worker/SearchDirectory.php @@ -27,7 +27,7 @@ class SearchDirectory return; } - $data = Cache::get('SearchDirectory:' . $search); + $data = DI::cache()->get('SearchDirectory:' . $search); if (!is_null($data)) { // Only search for the same item every 24 hours if (time() < $data + (60 * 60 * 24)) { From a38b0f7eaf91b7c202cc3e87fef853c601faf394 Mon Sep 17 00:00:00 2001 From: nupplaPhil Date: Tue, 7 Jan 2020 00:51:02 +0100 Subject: [PATCH 6/6] Move remaining namespaces and delete Core\Cache.php --- mod/ping.php | 2 +- mod/poco.php | 2 -- src/Content/OEmbed.php | 2 +- src/Content/Text/BBCode.php | 1 - src/Content/Widget/TrendingTags.php | 2 -- src/Core/Cache.php | 33 ------------------------ src/Core/Lock/DatabaseLock.php | 2 +- src/Core/Update.php | 1 + src/Model/Photo.php | 2 +- src/Model/Profile.php | 2 +- src/Model/Term.php | 2 +- src/Module/Search/Index.php | 3 --- src/Network/Probe.php | 2 +- src/Protocol/ActivityPub/Transmitter.php | 2 +- src/Protocol/Diaspora.php | 2 +- src/Protocol/OStatus.php | 2 +- src/Util/Images.php | 1 - src/Util/JsonLD.php | 2 +- src/Worker/CronJobs.php | 1 - src/Worker/SearchDirectory.php | 2 +- tests/Util/DbaLockMockTrait.php | 2 +- 21 files changed, 14 insertions(+), 56 deletions(-) delete mode 100644 src/Core/Cache.php diff --git a/mod/ping.php b/mod/ping.php index d00d0988a..26d0efb37 100644 --- a/mod/ping.php +++ b/mod/ping.php @@ -6,7 +6,7 @@ use Friendica\App; use Friendica\Content\ForumManager; use Friendica\Content\Text\BBCode; -use Friendica\Core\Cache; +use Friendica\Core\Cache\Cache; use Friendica\Core\Config; use Friendica\Core\Hook; use Friendica\Core\L10n; diff --git a/mod/poco.php b/mod/poco.php index b21dbf313..595a4bd2e 100644 --- a/mod/poco.php +++ b/mod/poco.php @@ -6,12 +6,10 @@ use Friendica\App; use Friendica\Content\Text\BBCode; -use Friendica\Core\Cache; use Friendica\Core\Config; use Friendica\Core\Logger; use Friendica\Core\Protocol; use Friendica\Core\Renderer; -use Friendica\Core\System; use Friendica\Database\DBA; use Friendica\DI; use Friendica\Protocol\PortableContact; diff --git a/src/Content/OEmbed.php b/src/Content/OEmbed.php index 6c62d6cfd..4bcb485fc 100644 --- a/src/Content/OEmbed.php +++ b/src/Content/OEmbed.php @@ -10,7 +10,7 @@ use DOMNode; use DOMText; use DOMXPath; use Exception; -use Friendica\Core\Cache; +use Friendica\Core\Cache\Cache; use Friendica\Core\Config; use Friendica\Core\Hook; use Friendica\Core\L10n; diff --git a/src/Content/Text/BBCode.php b/src/Content/Text/BBCode.php index 63e9c55dc..19ff88a9c 100644 --- a/src/Content/Text/BBCode.php +++ b/src/Content/Text/BBCode.php @@ -10,7 +10,6 @@ use DOMXPath; use Exception; use Friendica\Content\OEmbed; use Friendica\Content\Smilies; -use Friendica\Core\Cache; use Friendica\Core\Config; use Friendica\Core\Hook; use Friendica\Core\L10n; diff --git a/src/Content/Widget/TrendingTags.php b/src/Content/Widget/TrendingTags.php index a7cfa8557..4ac8a1119 100644 --- a/src/Content/Widget/TrendingTags.php +++ b/src/Content/Widget/TrendingTags.php @@ -2,10 +2,8 @@ namespace Friendica\Content\Widget; -use Friendica\Core\Cache; use Friendica\Core\L10n; use Friendica\Core\Renderer; -use Friendica\Database\DBA; use Friendica\Model\Term; /** diff --git a/src/Core/Cache.php b/src/Core/Cache.php deleted file mode 100644 index 4d5d8f087..000000000 --- a/src/Core/Cache.php +++ /dev/null @@ -1,33 +0,0 @@ -