99namespace OC \Comments ;
1010
1111use OCP \AppFramework \Utility \ITimeFactory ;
12+ use OCP \Cache \CappedMemoryCache ;
1213use OCP \Comments \CommentsEvent ;
1314use OCP \Comments \Events \BeforeCommentUpdatedEvent ;
1415use OCP \Comments \Events \CommentAddedEvent ;
3435use Psr \Log \LoggerInterface ;
3536
3637class Manager implements ICommentsManager {
37- /** @var IComment[] */
38- protected array $ commentsCache = [];
38+ protected CappedMemoryCache $ commentsCache ;
3939
4040 /** @var \Closure[] */
4141 protected array $ eventHandlerClosures = [];
@@ -56,6 +56,7 @@ public function __construct(
5656 protected IRootFolder $ rootFolder ,
5757 protected IEventDispatcher $ eventDispatcher ,
5858 ) {
59+ $ this ->commentsCache = new CappedMemoryCache (256 );
5960 }
6061
6162 /**
@@ -1322,7 +1323,7 @@ public function deleteReferencesOfActor($actorType, $actorId): bool {
13221323 ->setParameter ('id ' , $ actorId );
13231324
13241325 $ affectedRows = $ qb ->executeStatement ();
1325- $ this ->commentsCache = [] ;
1326+ $ this ->commentsCache -> clear () ;
13261327 return true ;
13271328 }
13281329
@@ -1342,7 +1343,7 @@ public function deleteCommentsAtObject($objectType, $objectId): bool {
13421343 ->setParameter ('id ' , $ objectId );
13431344
13441345 $ affectedRows = $ qb ->executeStatement ();
1345- $ this ->commentsCache = [] ;
1346+ $ this ->commentsCache -> clear () ;
13461347 return true ;
13471348 }
13481349
@@ -1602,7 +1603,7 @@ public function deleteCommentsExpiredAtObject(string $objectType, string $object
16021603
16031604 $ affectedRows = $ qb ->executeStatement ();
16041605
1605- $ this ->commentsCache = [] ;
1606+ $ this ->commentsCache -> clear () ;
16061607
16071608 return $ affectedRows > 0 ;
16081609 }
0 commit comments