Merge pull request #8072 from nupplaphil/task/Cache_to_DI

Replace Core\Cache wrapper with DI::cache() method
This commit is contained in:
Hypolite Petovan 2020-01-10 08:46:03 -05:00 committed by GitHub
commit 36190d1e79
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
21 changed files with 60 additions and 168 deletions

View file

@ -7,7 +7,7 @@ namespace Friendica\Protocol\ActivityPub;
use Friendica\Content\Feature;
use Friendica\Content\Text\BBCode;
use Friendica\Content\Text\Plaintext;
use Friendica\Core\Cache;
use Friendica\Core\Cache\Cache;
use Friendica\Core\Config;
use Friendica\Core\Logger;
use Friendica\Core\Protocol;
@ -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;
}
@ -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

@ -13,7 +13,7 @@ namespace Friendica\Protocol;
use Friendica\Content\Feature;
use Friendica\Content\Text\BBCode;
use Friendica\Content\Text\Markdown;
use Friendica\Core\Cache;
use Friendica\Core\Cache\Cache;
use Friendica\Core\Config;
use Friendica\Core\L10n;
use Friendica\Core\Logger;
@ -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;
}
@ -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);
}
@ -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;
}
@ -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;
}
@ -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;
}
@ -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

@ -8,7 +8,7 @@ use DOMDocument;
use DOMXPath;
use Friendica\Content\Text\BBCode;
use Friendica\Content\Text\HTML;
use Friendica\Core\Cache;
use Friendica\Core\Cache\Cache;
use Friendica\Core\Config;
use Friendica\Core\L10n;
use Friendica\Core\Lock;
@ -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'];
@ -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);