fix(comments): Use capped memory cache for comments

Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Joas Schilling 2026-06-09 07:17:59 +02:00 committed by backportbot[bot]
parent 5df2c635e4
commit 399643c121

View file

@ -8,6 +8,7 @@
namespace OC\Comments;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\Cache\CappedMemoryCache;
use OCP\Comments\CommentsEvent;
use OCP\Comments\Events\BeforeCommentUpdatedEvent;
use OCP\Comments\Events\CommentAddedEvent;
@ -33,8 +34,7 @@ use OCP\Util;
use Psr\Log\LoggerInterface;
class Manager implements ICommentsManager {
/** @var IComment[] */
protected array $commentsCache = [];
protected CappedMemoryCache $commentsCache;
/** @var \Closure[] */
protected array $eventHandlerClosures = [];
@ -55,6 +55,7 @@ class Manager implements ICommentsManager {
protected IRootFolder $rootFolder,
protected IEventDispatcher $eventDispatcher,
) {
$this->commentsCache = new CappedMemoryCache(256);
}
/**
@ -1299,7 +1300,7 @@ class Manager implements ICommentsManager {
->setParameter('id', $actorId);
$affectedRows = $qb->executeStatement();
$this->commentsCache = [];
$this->commentsCache->clear();
return true;
}
@ -1318,7 +1319,7 @@ class Manager implements ICommentsManager {
->setParameter('id', $objectId);
$affectedRows = $qb->executeStatement();
$this->commentsCache = [];
$this->commentsCache->clear();
return true;
}
@ -1568,7 +1569,7 @@ class Manager implements ICommentsManager {
$affectedRows = $qb->executeStatement();
$this->commentsCache = [];
$this->commentsCache->clear();
return $affectedRows > 0;
}