mirror of
https://github.com/friendica/friendica
synced 2025-04-23 08:30:10 +00:00
Cache the AP delivery process
This commit is contained in:
parent
be7bd10678
commit
51dbffd396
3 changed files with 34 additions and 3 deletions
|
@ -22,6 +22,7 @@ use Friendica\Model\Profile;
|
|||
use Friendica\Core\Config;
|
||||
use Friendica\Object\Image;
|
||||
use Friendica\Protocol\ActivityPub;
|
||||
use Friendica\Core\Cache;
|
||||
|
||||
/**
|
||||
* @brief ActivityPub Transmitter Protocol class
|
||||
|
@ -480,6 +481,27 @@ class Transmitter
|
|||
return $type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Creates the activity or fetches it from the cache
|
||||
*
|
||||
* @param integer $item_id
|
||||
*
|
||||
* @return array with the activity
|
||||
*/
|
||||
public static function createCachedActivityFromItem($item_id)
|
||||
{
|
||||
$cachekey = "APDelivery:createActivity:".$item_id;
|
||||
$data = Cache::get($cachekey);
|
||||
if (!is_null($data)) {
|
||||
return $data;
|
||||
}
|
||||
|
||||
$data = ActivityPub\Transmitter::createActivityFromItem($item_id);
|
||||
|
||||
Cache::set($cachekey, $data, CACHE_QUARTER_HOUR);
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Creates an activity array for a given item id
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue