Browse Source

Move Cache::get() to DI::cache()->get()

pull/8072/head
nupplaPhil 2 years ago
parent
commit
fe078410a1
No known key found for this signature in database GPG Key ID: D8365C3D36B77D90
  1. 2
      mod/ping.php
  2. 2
      mod/poco.php
  3. 2
      src/Content/OEmbed.php
  4. 4
      src/Content/Text/BBCode.php
  5. 13
      src/Core/Cache.php
  6. 2
      src/Model/Photo.php
  7. 4
      src/Model/Profile.php
  8. 4
      src/Model/Term.php
  9. 2
      src/Module/Search/Index.php
  10. 2
      src/Network/Probe.php
  11. 2
      src/Protocol/ActivityPub/Transmitter.php
  12. 6
      src/Protocol/Diaspora.php
  13. 2
      src/Protocol/OStatus.php
  14. 2
      src/Util/Images.php
  15. 2
      src/Util/JsonLD.php
  16. 2
      src/Worker/SearchDirectory.php

2
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`

2
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);

2
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

4
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;
}

13
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);
}
}

2
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

4
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 {

4
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`

2
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)) {

2
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;
}

2
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;
}

6
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;
}

2
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'];

2
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);

2
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;
}

2
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)) {

Loading…
Cancel
Save