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

This commit is contained in:
Philipp Holzer 2020-01-07 00:45:49 +01:00
parent f68929633b
commit fe078410a1
No known key found for this signature in database
GPG key ID: D8365C3D36B77D90
16 changed files with 20 additions and 33 deletions

View file

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

View file

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

View file

@ -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

View file

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

View file

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

View file

@ -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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -40,7 +40,7 @@ class JsonLD
exit();
}
$result = Cache::get('documentLoader:' . $url);
$result = DI::cache()->get('documentLoader:' . $url);
if (!is_null($result)) {
return $result;
}

View file

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