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

@ -6,7 +6,7 @@
*/
namespace Friendica\Model;
use Friendica\Core\Cache;
use Friendica\Core\Cache\Cache;
use Friendica\Core\Config;
use Friendica\Core\L10n;
use Friendica\Core\Logger;
@ -540,7 +540,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
@ -563,7 +563,7 @@ class Photo
DBA::escape(L10n::t("Contact Photos"))
);
}
Cache::set($key, $albums, Cache::DAY);
DI::cache()->set($key, $albums, Cache::DAY);
}
return $albums;
}
@ -576,7 +576,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

@ -10,7 +10,7 @@ use Friendica\Content\ForumManager;
use Friendica\Content\Text\BBCode;
use Friendica\Content\Text\HTML;
use Friendica\Content\Widget\ContactBlock;
use Friendica\Core\Cache;
use Friendica\Core\Cache\Cache;
use Friendica\Core\Config;
use Friendica\Core\Hook;
use Friendica\Core\L10n;
@ -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`
@ -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);
}
}
@ -1066,11 +1066,11 @@ 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 {
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

@ -4,7 +4,7 @@
*/
namespace Friendica\Model;
use Friendica\Core\Cache;
use Friendica\Core\Cache\Cache;
use Friendica\Core\Logger;
use Friendica\Database\DBA;
use Friendica\DI;
@ -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`
@ -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);
}
}
@ -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`
@ -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);
}
}