Merge pull request #8072 from nupplaphil/task/Cache_to_DI
Replace Core\Cache wrapper with DI::cache() method
This commit is contained in:
commit
36190d1e79
|
@ -6,7 +6,7 @@
|
||||||
use Friendica\App;
|
use Friendica\App;
|
||||||
use Friendica\Content\ForumManager;
|
use Friendica\Content\ForumManager;
|
||||||
use Friendica\Content\Text\BBCode;
|
use Friendica\Content\Text\BBCode;
|
||||||
use Friendica\Core\Cache;
|
use Friendica\Core\Cache\Cache;
|
||||||
use Friendica\Core\Config;
|
use Friendica\Core\Config;
|
||||||
use Friendica\Core\Hook;
|
use Friendica\Core\Hook;
|
||||||
use Friendica\Core\L10n;
|
use Friendica\Core\L10n;
|
||||||
|
@ -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`
|
||||||
|
@ -208,7 +208,7 @@ function ping_init(App $a)
|
||||||
DBA::escape(DateTimeFormat::utcNow())
|
DBA::escape(DateTimeFormat::utcNow())
|
||||||
);
|
);
|
||||||
if (DBA::isResult($ev)) {
|
if (DBA::isResult($ev)) {
|
||||||
Cache::set($cachekey, $ev, Cache::HOUR);
|
DI::cache()->set($cachekey, $ev, Cache::HOUR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,13 +6,12 @@
|
||||||
|
|
||||||
use Friendica\App;
|
use Friendica\App;
|
||||||
use Friendica\Content\Text\BBCode;
|
use Friendica\Content\Text\BBCode;
|
||||||
use Friendica\Core\Cache;
|
|
||||||
use Friendica\Core\Config;
|
use Friendica\Core\Config;
|
||||||
use Friendica\Core\Logger;
|
use Friendica\Core\Logger;
|
||||||
use Friendica\Core\Protocol;
|
use Friendica\Core\Protocol;
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
use Friendica\Core\System;
|
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
|
use Friendica\DI;
|
||||||
use Friendica\Protocol\PortableContact;
|
use Friendica\Protocol\PortableContact;
|
||||||
use Friendica\Util\DateTimeFormat;
|
use Friendica\Util\DateTimeFormat;
|
||||||
use Friendica\Util\Strings;
|
use Friendica\Util\Strings;
|
||||||
|
@ -255,10 +254,10 @@ 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);
|
||||||
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
|
// Non connected persons can only see the keywords of a Diaspora account
|
||||||
|
|
|
@ -10,7 +10,7 @@ use DOMNode;
|
||||||
use DOMText;
|
use DOMText;
|
||||||
use DOMXPath;
|
use DOMXPath;
|
||||||
use Exception;
|
use Exception;
|
||||||
use Friendica\Core\Cache;
|
use Friendica\Core\Cache\Cache;
|
||||||
use Friendica\Core\Config;
|
use Friendica\Core\Config;
|
||||||
use Friendica\Core\Hook;
|
use Friendica\Core\Hook;
|
||||||
use Friendica\Core\L10n;
|
use Friendica\Core\L10n;
|
||||||
|
@ -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
|
||||||
|
@ -125,7 +125,7 @@ class OEmbed
|
||||||
$cache_ttl = Cache::FIVE_MINUTES;
|
$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') {
|
if ($oembed->type == 'error') {
|
||||||
|
|
|
@ -10,7 +10,6 @@ use DOMXPath;
|
||||||
use Exception;
|
use Exception;
|
||||||
use Friendica\Content\OEmbed;
|
use Friendica\Content\OEmbed;
|
||||||
use Friendica\Content\Smilies;
|
use Friendica\Content\Smilies;
|
||||||
use Friendica\Core\Cache;
|
|
||||||
use Friendica\Core\Config;
|
use Friendica\Core\Config;
|
||||||
use Friendica\Core\Hook;
|
use Friendica\Core\Hook;
|
||||||
use Friendica\Core\L10n;
|
use Friendica\Core\L10n;
|
||||||
|
@ -1070,7 +1069,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();
|
||||||
|
@ -1112,7 +1111,7 @@ class BBCode
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Cache::set($cache_key, $text);
|
DI::cache()->set($cache_key, $text);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $text;
|
return $text;
|
||||||
|
@ -1143,7 +1142,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;
|
||||||
}
|
}
|
||||||
|
@ -1194,7 +1193,7 @@ class BBCode
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Cache::set($cache_key, $text);
|
DI::cache()->set($cache_key, $text);
|
||||||
|
|
||||||
return $text;
|
return $text;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,10 +2,8 @@
|
||||||
|
|
||||||
namespace Friendica\Content\Widget;
|
namespace Friendica\Content\Widget;
|
||||||
|
|
||||||
use Friendica\Core\Cache;
|
|
||||||
use Friendica\Core\L10n;
|
use Friendica\Core\L10n;
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
use Friendica\Database\DBA;
|
|
||||||
use Friendica\Model\Term;
|
use Friendica\Model\Term;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,102 +0,0 @@
|
||||||
<?php
|
|
||||||
/**
|
|
||||||
* @file src/Core/Cache.php
|
|
||||||
*/
|
|
||||||
namespace Friendica\Core;
|
|
||||||
|
|
||||||
use Friendica\Core\Cache\Cache as CacheClass;
|
|
||||||
use Friendica\DI;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Class for storing data for a short time
|
|
||||||
*/
|
|
||||||
class Cache
|
|
||||||
{
|
|
||||||
/** @deprecated Use CacheClass::MONTH */
|
|
||||||
const MONTH = CacheClass::MONTH;
|
|
||||||
/** @deprecated Use CacheClass::WEEK */
|
|
||||||
const WEEK = CacheClass::WEEK;
|
|
||||||
/** @deprecated Use CacheClass::DAY */
|
|
||||||
const DAY = CacheClass::DAY;
|
|
||||||
/** @deprecated Use CacheClass::HOUR */
|
|
||||||
const HOUR = CacheClass::HOUR;
|
|
||||||
/** @deprecated Use CacheClass::HALF_HOUR */
|
|
||||||
const HALF_HOUR = CacheClass::HALF_HOUR;
|
|
||||||
/** @deprecated Use CacheClass::QUARTER_HOUR */
|
|
||||||
const QUARTER_HOUR = CacheClass::QUARTER_HOUR;
|
|
||||||
/** @deprecated Use CacheClass::FIVE_MINUTES */
|
|
||||||
const FIVE_MINUTES = CacheClass::FIVE_MINUTES;
|
|
||||||
/** @deprecated Use CacheClass::MINUTE */
|
|
||||||
const MINUTE = CacheClass::MINUTE;
|
|
||||||
/** @deprecated Use CacheClass::INFINITE */
|
|
||||||
const INFINITE = CacheClass::INFINITE;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Returns all the cache keys sorted alphabetically
|
|
||||||
*
|
|
||||||
* @param string $prefix Prefix of the keys (optional)
|
|
||||||
*
|
|
||||||
* @return array Empty if the driver doesn't support this feature
|
|
||||||
* @throws \Exception
|
|
||||||
*/
|
|
||||||
public static function getAllKeys($prefix = null)
|
|
||||||
{
|
|
||||||
return DI::cache()->getAllKeys($prefix);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Delete a value from the cache
|
|
||||||
*
|
|
||||||
* @param string $key The key to the cached data
|
|
||||||
*
|
|
||||||
* @return bool
|
|
||||||
* @throws \Exception
|
|
||||||
*/
|
|
||||||
public static function delete($key)
|
|
||||||
{
|
|
||||||
return DI::cache()->delete($key);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Remove outdated data from the cache
|
|
||||||
*
|
|
||||||
* @param boolean $outdated just remove outdated values
|
|
||||||
*
|
|
||||||
* @return bool
|
|
||||||
* @throws \Exception
|
|
||||||
*/
|
|
||||||
public static function clear($outdated = true)
|
|
||||||
{
|
|
||||||
return DI::cache()->clear($outdated);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
namespace Friendica\Core\Lock;
|
namespace Friendica\Core\Lock;
|
||||||
|
|
||||||
use Friendica\Core\Cache;
|
use Friendica\Core\Cache\Cache;
|
||||||
use Friendica\Database\Database;
|
use Friendica\Database\Database;
|
||||||
use Friendica\Util\DateTimeFormat;
|
use Friendica\Util\DateTimeFormat;
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ use Friendica\Database\DBA;
|
||||||
use Friendica\Database\DBStructure;
|
use Friendica\Database\DBStructure;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
use Friendica\Util\Strings;
|
use Friendica\Util\Strings;
|
||||||
|
use Friendica\Core\Cache\Cache;
|
||||||
|
|
||||||
class Update
|
class Update
|
||||||
{
|
{
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
*/
|
*/
|
||||||
namespace Friendica\Model;
|
namespace Friendica\Model;
|
||||||
|
|
||||||
use Friendica\Core\Cache;
|
use Friendica\Core\Cache\Cache;
|
||||||
use Friendica\Core\Config;
|
use Friendica\Core\Config;
|
||||||
use Friendica\Core\L10n;
|
use Friendica\Core\L10n;
|
||||||
use Friendica\Core\Logger;
|
use Friendica\Core\Logger;
|
||||||
|
@ -540,7 +540,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
|
||||||
|
@ -563,7 +563,7 @@ class Photo
|
||||||
DBA::escape(L10n::t("Contact Photos"))
|
DBA::escape(L10n::t("Contact Photos"))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
Cache::set($key, $albums, Cache::DAY);
|
DI::cache()->set($key, $albums, Cache::DAY);
|
||||||
}
|
}
|
||||||
return $albums;
|
return $albums;
|
||||||
}
|
}
|
||||||
|
@ -576,7 +576,7 @@ class Photo
|
||||||
public static function clearAlbumCache($uid)
|
public static function clearAlbumCache($uid)
|
||||||
{
|
{
|
||||||
$key = "photo_albums:".$uid.":".local_user().":".remote_user();
|
$key = "photo_albums:".$uid.":".local_user().":".remote_user();
|
||||||
Cache::set($key, null, Cache::DAY);
|
DI::cache()->set($key, null, Cache::DAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -10,7 +10,7 @@ use Friendica\Content\ForumManager;
|
||||||
use Friendica\Content\Text\BBCode;
|
use Friendica\Content\Text\BBCode;
|
||||||
use Friendica\Content\Text\HTML;
|
use Friendica\Content\Text\HTML;
|
||||||
use Friendica\Content\Widget\ContactBlock;
|
use Friendica\Content\Widget\ContactBlock;
|
||||||
use Friendica\Core\Cache;
|
use Friendica\Core\Cache\Cache;
|
||||||
use Friendica\Core\Config;
|
use Friendica\Core\Config;
|
||||||
use Friendica\Core\Hook;
|
use Friendica\Core\Hook;
|
||||||
use Friendica\Core\L10n;
|
use Friendica\Core\L10n;
|
||||||
|
@ -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`
|
||||||
|
@ -608,7 +608,7 @@ class Profile
|
||||||
);
|
);
|
||||||
if (DBA::isResult($s)) {
|
if (DBA::isResult($s)) {
|
||||||
$r = DBA::toArray($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
|
// 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 {
|
||||||
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);
|
Logger::log('Not authenticated. Invoking reverse magic-auth for ' . $my_url, Logger::DEBUG);
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
*/
|
*/
|
||||||
namespace Friendica\Model;
|
namespace Friendica\Model;
|
||||||
|
|
||||||
use Friendica\Core\Cache;
|
use Friendica\Core\Cache\Cache;
|
||||||
use Friendica\Core\Logger;
|
use Friendica\Core\Logger;
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
|
@ -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`
|
||||||
|
@ -84,7 +84,7 @@ class Term
|
||||||
|
|
||||||
if (DBA::isResult($tagsStmt)) {
|
if (DBA::isResult($tagsStmt)) {
|
||||||
$tags = DBA::toArray($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)
|
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`
|
||||||
|
@ -129,7 +129,7 @@ class Term
|
||||||
|
|
||||||
if (DBA::isResult($tagsStmt)) {
|
if (DBA::isResult($tagsStmt)) {
|
||||||
$tags = DBA::toArray($tagsStmt);
|
$tags = DBA::toArray($tagsStmt);
|
||||||
Cache::set('local_trending_tags', $tags, Cache::HOUR);
|
DI::cache()->set('local_trending_tags', $tags, Cache::HOUR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,13 +2,10 @@
|
||||||
|
|
||||||
namespace Friendica\Module\Search;
|
namespace Friendica\Module\Search;
|
||||||
|
|
||||||
use Friendica\App\Arguments;
|
|
||||||
use Friendica\App\BaseURL;
|
|
||||||
use Friendica\Content\Nav;
|
use Friendica\Content\Nav;
|
||||||
use Friendica\Content\Pager;
|
use Friendica\Content\Pager;
|
||||||
use Friendica\Content\Text\HTML;
|
use Friendica\Content\Text\HTML;
|
||||||
use Friendica\Content\Widget;
|
use Friendica\Content\Widget;
|
||||||
use Friendica\Core\Cache;
|
|
||||||
use Friendica\Core\Cache\Cache as CacheClass;
|
use Friendica\Core\Cache\Cache as CacheClass;
|
||||||
use Friendica\Core\Config;
|
use Friendica\Core\Config;
|
||||||
use Friendica\Core\L10n;
|
use Friendica\Core\L10n;
|
||||||
|
@ -53,15 +50,15 @@ 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)) {
|
||||||
throw new HTTPException\TooManyRequestsException(L10n::t('Only one search per minute is permitted for not logged in users.'));
|
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 {
|
} 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ namespace Friendica\Network;
|
||||||
|
|
||||||
use DOMDocument;
|
use DOMDocument;
|
||||||
use DomXPath;
|
use DomXPath;
|
||||||
use Friendica\Core\Cache;
|
use Friendica\Core\Cache\Cache;
|
||||||
use Friendica\Core\Config;
|
use Friendica\Core\Config;
|
||||||
use Friendica\Core\Logger;
|
use Friendica\Core\Logger;
|
||||||
use Friendica\Core\Protocol;
|
use Friendica\Core\Protocol;
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
@ -409,7 +409,7 @@ class Probe
|
||||||
|
|
||||||
// Only store into the cache if the value seems to be valid
|
// Only store into the cache if the value seems to be valid
|
||||||
if (!in_array($data['network'], [Protocol::PHANTOM, Protocol::MAIL])) {
|
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;
|
return $data;
|
||||||
|
|
|
@ -7,7 +7,7 @@ namespace Friendica\Protocol\ActivityPub;
|
||||||
use Friendica\Content\Feature;
|
use Friendica\Content\Feature;
|
||||||
use Friendica\Content\Text\BBCode;
|
use Friendica\Content\Text\BBCode;
|
||||||
use Friendica\Content\Text\Plaintext;
|
use Friendica\Content\Text\Plaintext;
|
||||||
use Friendica\Core\Cache;
|
use Friendica\Core\Cache\Cache;
|
||||||
use Friendica\Core\Config;
|
use Friendica\Core\Config;
|
||||||
use Friendica\Core\Logger;
|
use Friendica\Core\Logger;
|
||||||
use Friendica\Core\Protocol;
|
use Friendica\Core\Protocol;
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
@ -827,7 +827,7 @@ class Transmitter
|
||||||
|
|
||||||
$data = ActivityPub\Transmitter::createActivityFromItem($item_id);
|
$data = ActivityPub\Transmitter::createActivityFromItem($item_id);
|
||||||
|
|
||||||
Cache::set($cachekey, $data, Cache::QUARTER_HOUR);
|
DI::cache()->set($cachekey, $data, Cache::QUARTER_HOUR);
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ namespace Friendica\Protocol;
|
||||||
use Friendica\Content\Feature;
|
use Friendica\Content\Feature;
|
||||||
use Friendica\Content\Text\BBCode;
|
use Friendica\Content\Text\BBCode;
|
||||||
use Friendica\Content\Text\Markdown;
|
use Friendica\Content\Text\Markdown;
|
||||||
use Friendica\Core\Cache;
|
use Friendica\Core\Cache\Cache;
|
||||||
use Friendica\Core\Config;
|
use Friendica\Core\Config;
|
||||||
use Friendica\Core\L10n;
|
use Friendica\Core\L10n;
|
||||||
use Friendica\Core\Logger;
|
use Friendica\Core\Logger;
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
@ -3272,7 +3272,7 @@ class Diaspora
|
||||||
Logger::log("Send participation for ".$item["guid"]." by ".$author, Logger::DEBUG);
|
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
|
// 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);
|
return self::buildAndTransmit($owner, $contact, "participation", $message);
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
@ -3628,7 +3628,7 @@ class Diaspora
|
||||||
|
|
||||||
$msg = ["type" => $type, "message" => $message];
|
$msg = ["type" => $type, "message" => $message];
|
||||||
|
|
||||||
Cache::set($cachekey, $msg, Cache::QUARTER_HOUR);
|
DI::cache()->set($cachekey, $msg, Cache::QUARTER_HOUR);
|
||||||
|
|
||||||
return $msg;
|
return $msg;
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
@ -3798,7 +3798,7 @@ class Diaspora
|
||||||
$comment['thread_parent_guid'] = $thread_parent_item['guid'];
|
$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);
|
return($comment);
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ use DOMDocument;
|
||||||
use DOMXPath;
|
use DOMXPath;
|
||||||
use Friendica\Content\Text\BBCode;
|
use Friendica\Content\Text\BBCode;
|
||||||
use Friendica\Content\Text\HTML;
|
use Friendica\Content\Text\HTML;
|
||||||
use Friendica\Core\Cache;
|
use Friendica\Core\Cache\Cache;
|
||||||
use Friendica\Core\Config;
|
use Friendica\Core\Config;
|
||||||
use Friendica\Core\L10n;
|
use Friendica\Core\L10n;
|
||||||
use Friendica\Core\Lock;
|
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)
|
// 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'];
|
||||||
|
@ -2246,7 +2246,7 @@ class OStatus
|
||||||
$feeddata = trim($doc->saveXML());
|
$feeddata = trim($doc->saveXML());
|
||||||
|
|
||||||
$msg = ['feed' => $feeddata, 'last_update' => $last_update];
|
$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);
|
Logger::log('Feed duration: ' . number_format(microtime(true) - $stamp, 3) . ' - ' . $owner_nick . ' - ' . $filter . ' - ' . $previous_created, Logger::DEBUG);
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
namespace Friendica\Util;
|
namespace Friendica\Util;
|
||||||
|
|
||||||
use Friendica\Core\Cache;
|
|
||||||
use Friendica\Core\Logger;
|
use Friendica\Core\Logger;
|
||||||
use Friendica\Core\System;
|
use Friendica\Core\System;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
|
@ -125,12 +124,12 @@ 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);
|
||||||
|
|
||||||
Cache::set($url, $data);
|
DI::cache()->set($url, $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
|
|
|
@ -4,9 +4,10 @@
|
||||||
*/
|
*/
|
||||||
namespace Friendica\Util;
|
namespace Friendica\Util;
|
||||||
|
|
||||||
use Friendica\Core\Cache;
|
use Friendica\Core\Cache\Cache;
|
||||||
use Friendica\Core\Logger;
|
use Friendica\Core\Logger;
|
||||||
use Exception;
|
use Exception;
|
||||||
|
use Friendica\DI;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This class contain methods to work with JsonLD data
|
* @brief This class contain methods to work with JsonLD data
|
||||||
|
@ -39,13 +40,13 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
$data = jsonld_default_document_loader($url);
|
$data = jsonld_default_document_loader($url);
|
||||||
Cache::set('documentLoader:' . $url, $data, Cache::DAY);
|
DI::cache()->set('documentLoader:' . $url, $data, Cache::DAY);
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
namespace Friendica\Worker;
|
namespace Friendica\Worker;
|
||||||
|
|
||||||
use Friendica\App;
|
use Friendica\App;
|
||||||
use Friendica\Core\Cache;
|
|
||||||
use Friendica\Core\Config;
|
use Friendica\Core\Config;
|
||||||
use Friendica\Core\Logger;
|
use Friendica\Core\Logger;
|
||||||
use Friendica\Core\Protocol;
|
use Friendica\Core\Protocol;
|
||||||
|
@ -154,7 +153,7 @@ class CronJobs
|
||||||
}
|
}
|
||||||
|
|
||||||
// clear old cache
|
// clear old cache
|
||||||
Cache::clear();
|
DI::cache()->clear();
|
||||||
|
|
||||||
// clear old item cache files
|
// clear old item cache files
|
||||||
clear_cache();
|
clear_cache();
|
||||||
|
|
|
@ -4,12 +4,13 @@
|
||||||
*/
|
*/
|
||||||
namespace Friendica\Worker;
|
namespace Friendica\Worker;
|
||||||
|
|
||||||
use Friendica\Core\Cache;
|
use Friendica\Core\Cache\Cache;
|
||||||
use Friendica\Core\Config;
|
use Friendica\Core\Config;
|
||||||
use Friendica\Core\Logger;
|
use Friendica\Core\Logger;
|
||||||
use Friendica\Core\Protocol;
|
use Friendica\Core\Protocol;
|
||||||
use Friendica\Core\Search;
|
use Friendica\Core\Search;
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
|
use Friendica\DI;
|
||||||
use Friendica\Model\GContact;
|
use Friendica\Model\GContact;
|
||||||
use Friendica\Model\GServer;
|
use Friendica\Model\GServer;
|
||||||
use Friendica\Network\Probe;
|
use Friendica\Network\Probe;
|
||||||
|
@ -26,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)) {
|
||||||
|
@ -80,6 +81,6 @@ class SearchDirectory
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Cache::set('SearchDirectory:' . $search, time(), Cache::DAY);
|
DI::cache()->set('SearchDirectory:' . $search, time(), Cache::DAY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
namespace Friendica\Test\Util;
|
namespace Friendica\Test\Util;
|
||||||
|
|
||||||
use Friendica\Core\Cache;
|
use Friendica\Core\Cache\Cache;
|
||||||
use Friendica\Core\Lock\DatabaseLock;
|
use Friendica\Core\Lock\DatabaseLock;
|
||||||
|
|
||||||
trait DbaLockMockTrait
|
trait DbaLockMockTrait
|
||||||
|
|
Loading…
Reference in New Issue
Block a user