Instead of creating a CacheEntryRemovedEvent for each deleted files, create a single CacheEntriesRemovedEvent which wrap multiple CacheEntryRemovedEvent. This allow listener to optimize the query they do when multiple files are deleted at the same time (e.g. when deleting a folder). Signed-off-by: Carl Schwan <carl.schwan@nextclound.com>pull/54277/head
parent
ebfdbf86b9
commit
fd3878448b
@ -0,0 +1,35 @@ |
||||
<?php |
||||
|
||||
declare(strict_types=1); |
||||
|
||||
/** |
||||
* SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors |
||||
* SPDX-License-Identifier: AGPL-3.0-or-later |
||||
*/ |
||||
namespace OCP\Files\Cache; |
||||
|
||||
use OCP\EventDispatcher\Event; |
||||
|
||||
/** |
||||
* Meta-event wrapping multiple CacheEntryRemovedEvent for when an existing |
||||
* entry in the cache gets removed. |
||||
* |
||||
* @since 32.0.0 |
||||
*/ |
||||
#[\OCP\AppFramework\Attribute\Listenable(since: '32.0.0')] |
||||
class CacheEntriesRemovedEvent extends Event { |
||||
/** |
||||
* @param CacheEntryRemovedEvent[] $cacheEntryRemovedEvents |
||||
*/ |
||||
public function __construct( |
||||
private readonly array $cacheEntryRemovedEvents, |
||||
) { |
||||
} |
||||
|
||||
/** |
||||
* @return CacheEntryRemovedEvent[] |
||||
*/ |
||||
public function getCacheEntryRemovedEvents(): array { |
||||
return $this->cacheEntryRemovedEvents; |
||||
} |
||||
} |
||||
Loading…
Reference in new issue