Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/spreed.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDariusz Olszewski <starypatyk@users.noreply.github.com>2022-08-17 22:21:53 +0300
committerDariusz Olszewski <starypatyk@users.noreply.github.com>2022-08-17 22:22:27 +0300
commit03f64768cc8219e7718980d7a6eef4d227b83de7 (patch)
treeb1a3075d7bd7f4d6701891ade5ddf96c966b4cae /lib/Share/RoomShareProvider.php
parent3e17b5c95d7c4c572d8e383f3579a7a0c82ea79f (diff)
Invalidate cache on delete/update function calls
(Nuclear option - clean the cache entirely) Signed-off-by: Dariusz Olszewski <starypatyk@users.noreply.github.com>
Diffstat (limited to 'lib/Share/RoomShareProvider.php')
-rw-r--r--lib/Share/RoomShareProvider.php19
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/Share/RoomShareProvider.php b/lib/Share/RoomShareProvider.php
index 653083d96..a4cdee7e4 100644
--- a/lib/Share/RoomShareProvider.php
+++ b/lib/Share/RoomShareProvider.php
@@ -109,6 +109,13 @@ class RoomShareProvider implements IShareProvider {
$this->sharesByIdCache = new CappedMemoryCache();
}
+ /*
+ * Clean sharesByIdCache
+ */
+ private function cleanSharesByIdCache() {
+ $this->sharesByIdCache = new CappedMemoryCache();
+ }
+
public static function register(IEventDispatcher $dispatcher): void {
$listener = static function (RoomEvent $event): void {
$room = $event->getRoom();
@@ -318,6 +325,8 @@ class RoomShareProvider implements IShareProvider {
* @return IShare The share object
*/
public function update(IShare $share): IShare {
+ $this->cleanSharesByIdCache();
+
$update = $this->dbConnection->getQueryBuilder();
$update->update('share')
->where($update->expr()->eq('id', $update->createNamedParameter($share->getId())))
@@ -361,6 +370,8 @@ class RoomShareProvider implements IShareProvider {
* @param IShare $share
*/
public function delete(IShare $share): void {
+ $this->cleanSharesByIdCache();
+
$delete = $this->dbConnection->getQueryBuilder();
$delete->delete('share')
->where($delete->expr()->eq('id', $delete->createNamedParameter($share->getId())));
@@ -380,6 +391,8 @@ class RoomShareProvider implements IShareProvider {
* @param string $recipient UserId of the recipient
*/
public function deleteFromSelf(IShare $share, $recipient): void {
+ $this->cleanSharesByIdCache();
+
// Check if there is a userroom share
$qb = $this->dbConnection->getQueryBuilder();
$stmt = $qb->select(['id', 'permissions'])
@@ -432,6 +445,8 @@ class RoomShareProvider implements IShareProvider {
* @throws GenericShareException In case the share could not be restored
*/
public function restore(IShare $share, string $recipient): IShare {
+ $this->cleanSharesByIdCache();
+
$qb = $this->dbConnection->getQueryBuilder();
$qb->select('permissions')
->from('share')
@@ -472,6 +487,8 @@ class RoomShareProvider implements IShareProvider {
* @return IShare
*/
public function move(IShare $share, $recipient): IShare {
+ $this->cleanSharesByIdCache();
+
// Check if there is a userroom share
$qb = $this->dbConnection->getQueryBuilder();
$stmt = $qb->select('id')
@@ -1110,6 +1127,8 @@ class RoomShareProvider implements IShareProvider {
* @param string|null $user
*/
public function deleteInRoom(string $roomToken, string $user = null): void {
+ $this->cleanSharesByIdCache();
+
//First delete all custom room shares for the original shares to be removed
$qb = $this->dbConnection->getQueryBuilder();
$qb->select('id')