Move Cache::get() to DI::cache()->get()
This commit is contained in:
parent
f68929633b
commit
fe078410a1
16 changed files with 20 additions and 33 deletions
|
@ -197,7 +197,7 @@ function ping_init(App $a)
|
||||||
}
|
}
|
||||||
|
|
||||||
$cachekey = "ping_init:".local_user();
|
$cachekey = "ping_init:".local_user();
|
||||||
$ev = Cache::get($cachekey);
|
$ev = DI::cache()->get($cachekey);
|
||||||
if (is_null($ev)) {
|
if (is_null($ev)) {
|
||||||
$ev = q(
|
$ev = q(
|
||||||
"SELECT type, start, adjust FROM `event`
|
"SELECT type, start, adjust FROM `event`
|
||||||
|
|
|
@ -256,7 +256,7 @@ function poco_init(App $a) {
|
||||||
if (isset($contact['account-type'])) {
|
if (isset($contact['account-type'])) {
|
||||||
$contact['contact-type'] = $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)) {
|
if (is_null($about)) {
|
||||||
$about = BBCode::convert($contact['about'], false);
|
$about = BBCode::convert($contact['about'], false);
|
||||||
DI::cache()->set("about:" . $contact['updated'] . ":" . $contact['nurl'], $about);
|
DI::cache()->set("about:" . $contact['updated'] . ":" . $contact['nurl'], $about);
|
||||||
|
|
|
@ -66,7 +66,7 @@ class OEmbed
|
||||||
if (DBA::isResult($oembed_record)) {
|
if (DBA::isResult($oembed_record)) {
|
||||||
$json_string = $oembed_record['content'];
|
$json_string = $oembed_record['content'];
|
||||||
} else {
|
} else {
|
||||||
$json_string = Cache::get($cache_key);
|
$json_string = DI::cache()->get($cache_key);
|
||||||
}
|
}
|
||||||
|
|
||||||
// These media files should now be caught in bbcode.php
|
// These media files should now be caught in bbcode.php
|
||||||
|
|
|
@ -1070,7 +1070,7 @@ class BBCode
|
||||||
private static function removePictureLinksCallback($match)
|
private static function removePictureLinksCallback($match)
|
||||||
{
|
{
|
||||||
$cache_key = 'remove:' . $match[1];
|
$cache_key = 'remove:' . $match[1];
|
||||||
$text = Cache::get($cache_key);
|
$text = DI::cache()->get($cache_key);
|
||||||
|
|
||||||
if (is_null($text)) {
|
if (is_null($text)) {
|
||||||
$a = DI::app();
|
$a = DI::app();
|
||||||
|
@ -1143,7 +1143,7 @@ class BBCode
|
||||||
}
|
}
|
||||||
|
|
||||||
$cache_key = 'clean:' . $match[1];
|
$cache_key = 'clean:' . $match[1];
|
||||||
$text = Cache::get($cache_key);
|
$text = DI::cache()->get($cache_key);
|
||||||
if (!is_null($text)) {
|
if (!is_null($text)) {
|
||||||
return $text;
|
return $text;
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,17 +30,4 @@ class Cache
|
||||||
const MINUTE = CacheClass::MINUTE;
|
const MINUTE = CacheClass::MINUTE;
|
||||||
/** @deprecated Use CacheClass::INFINITE */
|
/** @deprecated Use CacheClass::INFINITE */
|
||||||
const INFINITE = 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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -546,7 +546,7 @@ class Photo
|
||||||
$sql_extra = Security::getPermissionsSQLByUserId($uid);
|
$sql_extra = Security::getPermissionsSQLByUserId($uid);
|
||||||
|
|
||||||
$key = "photo_albums:".$uid.":".local_user().":".remote_user();
|
$key = "photo_albums:".$uid.":".local_user().":".remote_user();
|
||||||
$albums = Cache::get($key);
|
$albums = DI::cache()->get($key);
|
||||||
if (is_null($albums) || $update) {
|
if (is_null($albums) || $update) {
|
||||||
if (!Config::get("system", "no_count", false)) {
|
if (!Config::get("system", "no_count", false)) {
|
||||||
/// @todo This query needs to be renewed. It is really slow
|
/// @todo This query needs to be renewed. It is really slow
|
||||||
|
|
|
@ -586,7 +586,7 @@ class Profile
|
||||||
$bd_short = L10n::t('F d');
|
$bd_short = L10n::t('F d');
|
||||||
|
|
||||||
$cachekey = 'get_birthdays:' . local_user();
|
$cachekey = 'get_birthdays:' . local_user();
|
||||||
$r = Cache::get($cachekey);
|
$r = DI::cache()->get($cachekey);
|
||||||
if (is_null($r)) {
|
if (is_null($r)) {
|
||||||
$s = DBA::p(
|
$s = DBA::p(
|
||||||
"SELECT `event`.*, `event`.`id` AS `eid`, `contact`.* FROM `event`
|
"SELECT `event`.*, `event`.`id` AS `eid`, `contact`.* FROM `event`
|
||||||
|
@ -1066,7 +1066,7 @@ class Profile
|
||||||
|
|
||||||
// Avoid endless loops
|
// Avoid endless loops
|
||||||
$cachekey = 'zrlInit:' . $my_url;
|
$cachekey = 'zrlInit:' . $my_url;
|
||||||
if (Cache::get($cachekey)) {
|
if (DI::cache()->get($cachekey)) {
|
||||||
Logger::log('URL ' . $my_url . ' already tried to authenticate.', Logger::DEBUG);
|
Logger::log('URL ' . $my_url . ' already tried to authenticate.', Logger::DEBUG);
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -57,7 +57,7 @@ class Term
|
||||||
*/
|
*/
|
||||||
public static function getGlobalTrendingHashtags(int $period, $limit = 10)
|
public static function getGlobalTrendingHashtags(int $period, $limit = 10)
|
||||||
{
|
{
|
||||||
$tags = Cache::get('global_trending_tags');
|
$tags = DI::cache()->get('global_trending_tags');
|
||||||
|
|
||||||
if (!$tags) {
|
if (!$tags) {
|
||||||
$tagsStmt = DBA::p("SELECT t.`term`, COUNT(*) AS `score`
|
$tagsStmt = DBA::p("SELECT t.`term`, COUNT(*) AS `score`
|
||||||
|
@ -100,7 +100,7 @@ class Term
|
||||||
*/
|
*/
|
||||||
public static function getLocalTrendingHashtags(int $period, $limit = 10)
|
public static function getLocalTrendingHashtags(int $period, $limit = 10)
|
||||||
{
|
{
|
||||||
$tags = Cache::get('local_trending_tags');
|
$tags = DI::cache()->get('local_trending_tags');
|
||||||
|
|
||||||
if (!$tags) {
|
if (!$tags) {
|
||||||
$tagsStmt = DBA::p("SELECT t.`term`, COUNT(*) AS `score`
|
$tagsStmt = DBA::p("SELECT t.`term`, COUNT(*) AS `score`
|
||||||
|
|
|
@ -53,7 +53,7 @@ class Index extends BaseSearchModule
|
||||||
$crawl_permit_period = 10;
|
$crawl_permit_period = 10;
|
||||||
|
|
||||||
$remote = $_SERVER['REMOTE_ADDR'];
|
$remote = $_SERVER['REMOTE_ADDR'];
|
||||||
$result = Cache::get('remote_search:' . $remote);
|
$result = DI::cache()->get('remote_search:' . $remote);
|
||||||
if (!is_null($result)) {
|
if (!is_null($result)) {
|
||||||
$resultdata = json_decode($result);
|
$resultdata = json_decode($result);
|
||||||
if (($resultdata->time > (time() - $crawl_permit_period)) && ($resultdata->accesses > $free_crawls)) {
|
if (($resultdata->time > (time() - $crawl_permit_period)) && ($resultdata->accesses > $free_crawls)) {
|
||||||
|
|
|
@ -332,7 +332,7 @@ class Probe
|
||||||
public static function uri($uri, $network = '', $uid = -1, $cache = true)
|
public static function uri($uri, $network = '', $uid = -1, $cache = true)
|
||||||
{
|
{
|
||||||
if ($cache) {
|
if ($cache) {
|
||||||
$result = Cache::get('Probe::uri:' . $network . ':' . $uri);
|
$result = DI::cache()->get('Probe::uri:' . $network . ':' . $uri);
|
||||||
if (!is_null($result)) {
|
if (!is_null($result)) {
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -819,7 +819,7 @@ class Transmitter
|
||||||
$cachekey = 'APDelivery:createActivity:' . $item_id;
|
$cachekey = 'APDelivery:createActivity:' . $item_id;
|
||||||
|
|
||||||
if (!$force) {
|
if (!$force) {
|
||||||
$data = Cache::get($cachekey);
|
$data = DI::cache()->get($cachekey);
|
||||||
if (!is_null($data)) {
|
if (!is_null($data)) {
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3246,7 +3246,7 @@ class Diaspora
|
||||||
|
|
||||||
$cachekey = "diaspora:sendParticipation:".$item['guid'];
|
$cachekey = "diaspora:sendParticipation:".$item['guid'];
|
||||||
|
|
||||||
$result = Cache::get($cachekey);
|
$result = DI::cache()->get($cachekey);
|
||||||
if (!is_null($result)) {
|
if (!is_null($result)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -3524,7 +3524,7 @@ class Diaspora
|
||||||
{
|
{
|
||||||
$cachekey = "diaspora:buildStatus:".$item['guid'];
|
$cachekey = "diaspora:buildStatus:".$item['guid'];
|
||||||
|
|
||||||
$result = Cache::get($cachekey);
|
$result = DI::cache()->get($cachekey);
|
||||||
if (!is_null($result)) {
|
if (!is_null($result)) {
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
@ -3749,7 +3749,7 @@ class Diaspora
|
||||||
{
|
{
|
||||||
$cachekey = "diaspora:constructComment:".$item['guid'];
|
$cachekey = "diaspora:constructComment:".$item['guid'];
|
||||||
|
|
||||||
$result = Cache::get($cachekey);
|
$result = DI::cache()->get($cachekey);
|
||||||
if (!is_null($result)) {
|
if (!is_null($result)) {
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2185,7 +2185,7 @@ class OStatus
|
||||||
|
|
||||||
// Don't cache when the last item was posted less then 15 minutes ago (Cache duration)
|
// Don't cache when the last item was posted less then 15 minutes ago (Cache duration)
|
||||||
if ((time() - strtotime($owner['last-item'])) < 15*60) {
|
if ((time() - strtotime($owner['last-item'])) < 15*60) {
|
||||||
$result = Cache::get($cachekey);
|
$result = DI::cache()->get($cachekey);
|
||||||
if (!$nocache && !is_null($result)) {
|
if (!$nocache && !is_null($result)) {
|
||||||
Logger::log('Feed duration: ' . number_format(microtime(true) - $stamp, 3) . ' - ' . $owner_nick . ' - ' . $filter . ' - ' . $previous_created . ' (cached)', Logger::DEBUG);
|
Logger::log('Feed duration: ' . number_format(microtime(true) - $stamp, 3) . ' - ' . $owner_nick . ' - ' . $filter . ' - ' . $previous_created . ' (cached)', Logger::DEBUG);
|
||||||
$last_update = $result['last_update'];
|
$last_update = $result['last_update'];
|
||||||
|
|
|
@ -125,7 +125,7 @@ class Images
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
$data = Cache::get($url);
|
$data = DI::cache()->get($url);
|
||||||
|
|
||||||
if (empty($data) || !is_array($data)) {
|
if (empty($data) || !is_array($data)) {
|
||||||
$data = self::getInfoFromURL($url);
|
$data = self::getInfoFromURL($url);
|
||||||
|
|
|
@ -40,7 +40,7 @@ class JsonLD
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = Cache::get('documentLoader:' . $url);
|
$result = DI::cache()->get('documentLoader:' . $url);
|
||||||
if (!is_null($result)) {
|
if (!is_null($result)) {
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@ class SearchDirectory
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$data = Cache::get('SearchDirectory:' . $search);
|
$data = DI::cache()->get('SearchDirectory:' . $search);
|
||||||
if (!is_null($data)) {
|
if (!is_null($data)) {
|
||||||
// Only search for the same item every 24 hours
|
// Only search for the same item every 24 hours
|
||||||
if (time() < $data + (60 * 60 * 24)) {
|
if (time() < $data + (60 * 60 * 24)) {
|
||||||
|
|
Loading…
Reference in a new issue