Skip to content

Commit b816150

Browse files
authored
Merge branch 'master' into fix/theme-querystring
2 parents 402b71e + 0a10ad4 commit b816150

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

lib/private/Comments/Manager.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
namespace OC\Comments;
1010

1111
use OCP\AppFramework\Utility\ITimeFactory;
12+
use OCP\Cache\CappedMemoryCache;
1213
use OCP\Comments\CommentsEvent;
1314
use OCP\Comments\Events\BeforeCommentUpdatedEvent;
1415
use OCP\Comments\Events\CommentAddedEvent;
@@ -34,8 +35,7 @@
3435
use Psr\Log\LoggerInterface;
3536

3637
class 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

Comments
 (0)