Use cache key constants
This commit is contained in:
parent
10cdefa232
commit
610f8a086f
|
@ -44,7 +44,6 @@ use Friendica\Protocol\ActivityPub;
|
||||||
use Friendica\Protocol\Relay;
|
use Friendica\Protocol\Relay;
|
||||||
use Friendica\Util\DateTimeFormat;
|
use Friendica\Util\DateTimeFormat;
|
||||||
use Friendica\Util\HTTPSignature;
|
use Friendica\Util\HTTPSignature;
|
||||||
use Friendica\Util\JsonLD;
|
|
||||||
use Friendica\Util\LDSignature;
|
use Friendica\Util\LDSignature;
|
||||||
use Friendica\Util\Map;
|
use Friendica\Util\Map;
|
||||||
use Friendica\Util\Network;
|
use Friendica\Util\Network;
|
||||||
|
@ -59,6 +58,10 @@ use Friendica\Util\XML;
|
||||||
*/
|
*/
|
||||||
class Transmitter
|
class Transmitter
|
||||||
{
|
{
|
||||||
|
const CACHEKEY_FEATURED = 'transmitter:getFeatured:';
|
||||||
|
const CACHEKEY_CONTACTS = 'transmitter:getContacts:';
|
||||||
|
const CACHEKEY_OUTBOX = 'transmitter:getOutbox:';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add relay servers to the list of inboxes
|
* Add relay servers to the list of inboxes
|
||||||
*
|
*
|
||||||
|
@ -159,7 +162,7 @@ class Transmitter
|
||||||
public static function getContacts(array $owner, array $rel, string $module, int $page = null, string $requester = null, $nocache = false)
|
public static function getContacts(array $owner, array $rel, string $module, int $page = null, string $requester = null, $nocache = false)
|
||||||
{
|
{
|
||||||
if (empty($page)) {
|
if (empty($page)) {
|
||||||
$cachekey = 'transmitter:getContacts:' . $module . ':'. $owner['uid'];
|
$cachekey = self::CACHEKEY_CONTACTS . $module . ':'. $owner['uid'];
|
||||||
$result = DI::cache()->get($cachekey);
|
$result = DI::cache()->get($cachekey);
|
||||||
if (!$nocache && !is_null($result)) {
|
if (!$nocache && !is_null($result)) {
|
||||||
return $result;
|
return $result;
|
||||||
|
@ -251,7 +254,7 @@ class Transmitter
|
||||||
public static function getOutbox(array $owner, int $page = null, string $requester = '', $nocache = false)
|
public static function getOutbox(array $owner, int $page = null, string $requester = '', $nocache = false)
|
||||||
{
|
{
|
||||||
if (empty($page)) {
|
if (empty($page)) {
|
||||||
$cachekey = 'transmitter:getOutbox:' . $owner['uid'];
|
$cachekey = self::CACHEKEY_OUTBOX . $owner['uid'];
|
||||||
$result = DI::cache()->get($cachekey);
|
$result = DI::cache()->get($cachekey);
|
||||||
if (!$nocache && !is_null($result)) {
|
if (!$nocache && !is_null($result)) {
|
||||||
return $result;
|
return $result;
|
||||||
|
@ -339,15 +342,16 @@ class Transmitter
|
||||||
*/
|
*/
|
||||||
public static function getFeatured(array $owner, int $page = null, $nocache = false)
|
public static function getFeatured(array $owner, int $page = null, $nocache = false)
|
||||||
{
|
{
|
||||||
$owner_cid = Contact::getIdForURL($owner['url'], 0, false);
|
|
||||||
if (empty($page)) {
|
if (empty($page)) {
|
||||||
$cachekey = 'transmitter:getFeatured:' . $owner_cid;
|
$cachekey = self::CACHEKEY_FEATURED . $owner['uid'];
|
||||||
$result = DI::cache()->get($cachekey);
|
$result = DI::cache()->get($cachekey);
|
||||||
if (!$nocache && !is_null($result)) {
|
if (!$nocache && !is_null($result)) {
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$owner_cid = Contact::getIdForURL($owner['url'], 0, false);
|
||||||
|
|
||||||
$condition = ["`uri-id` IN (SELECT `uri-id` FROM `collection-view` WHERE `cid` = ? AND `type` = ?)",
|
$condition = ["`uri-id` IN (SELECT `uri-id` FROM `collection-view` WHERE `cid` = ? AND `type` = ?)",
|
||||||
$owner_cid, Post\Collection::FEATURED];
|
$owner_cid, Post\Collection::FEATURED];
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue