mirror of
https://github.com/friendica/friendica
synced 2025-04-24 04:30:11 +00:00
Delete the cache entry when the post is changed or deleted
This commit is contained in:
parent
7c9f10e58f
commit
da658cbf1d
6 changed files with 38 additions and 9 deletions
|
@ -36,17 +36,18 @@ class PageCache
|
|||
* Add content to the page cache
|
||||
*
|
||||
* @param string $page
|
||||
* @param int $uriid
|
||||
* @param mixed $content
|
||||
* @return void
|
||||
*/
|
||||
public static function add(string $page, $content)
|
||||
public static function add(string $page, int $uriid, $content)
|
||||
{
|
||||
if (!DI::config()->get('system', 'pagecache')) {
|
||||
return;
|
||||
}
|
||||
|
||||
DBA::delete('pagecache', ["`fetched` < ?", DateTimeFormat::utc('now - 5 minutes')]);
|
||||
DBA::insert('pagecache', ['page' => $page, 'content' => serialize($content), 'fetched' => DateTimeFormat::utcNow()], Database::INSERT_UPDATE);
|
||||
DBA::insert('pagecache', ['page' => $page, 'uri-id' => $uriid, 'content' => serialize($content), 'fetched' => DateTimeFormat::utcNow()], Database::INSERT_UPDATE);
|
||||
|
||||
Logger::debug('Page added', ['page' => $page]);
|
||||
}
|
||||
|
@ -70,4 +71,15 @@ class PageCache
|
|||
|
||||
return unserialize($pagecache['content']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the pagecache via its connected uri-id
|
||||
*
|
||||
* @param integer $uriid
|
||||
* @return void
|
||||
*/
|
||||
public static function deleteByUriId(int $uriid)
|
||||
{
|
||||
DBA::delete('pagecache', ['uri-id' => $uriid]);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue