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

This commit is contained in:
nupplaPhil 2020-01-07 00:41:20 +01:00
parent 3369dfaad9
commit f68929633b
No known key found for this signature in database
GPG Key ID: D8365C3D36B77D90
16 changed files with 25 additions and 39 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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