mirror of
https://github.com/nextcloud/server.git
synced 2026-06-15 11:41:20 -04:00
fix(comments): Use capped memory cache for comments
Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
parent
c9f1301ac7
commit
d397e7da3d
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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1322,7 +1323,7 @@ class Manager implements ICommentsManager {
|
|||
->setParameter('id', $actorId);
|
||||
|
||||
$affectedRows = $qb->executeStatement();
|
||||
$this->commentsCache = [];
|
||||
$this->commentsCache->clear();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -1342,7 +1343,7 @@ class Manager implements ICommentsManager {
|
|||
->setParameter('id', $objectId);
|
||||
|
||||
$affectedRows = $qb->executeStatement();
|
||||
$this->commentsCache = [];
|
||||
$this->commentsCache->clear();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -1601,7 +1602,7 @@ class Manager implements ICommentsManager {
|
|||
|
||||
$affectedRows = $qb->executeStatement();
|
||||
|
||||
$this->commentsCache = [];
|
||||
$this->commentsCache->clear();
|
||||
|
||||
return $affectedRows > 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue