mirror of
https://github.com/nextcloud/server.git
synced 2026-06-10 17:23:59 -04:00
fix(comments): Use capped memory cache for comments
Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
parent
5df2c635e4
commit
399643c121
1 changed files with 6 additions and 5 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue