Skip to content

Commit 9a1a49d

Browse files
authored
Merge pull request #504 from nextcloud/backport/500/stable30
[stable30] enh(TaskProcessingService): Cache result of getRegisteredTaskProcessingProviders
2 parents ff08233 + 0e3d958 commit 9a1a49d

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

lib/Service/ProvidersAI/TaskProcessingService.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
class TaskProcessingService {
2626
private ?ICache $cache = null;
27+
private ?array $registeredProviders = null;
2728

2829
public function __construct(
2930
ICacheFactory $cacheFactory,
@@ -42,14 +43,17 @@ public function __construct(
4243
*/
4344
public function getRegisteredTaskProcessingProviders(): array {
4445
try {
46+
if ($this->registeredProviders !== null) {
47+
return $this->registeredProviders;
48+
}
4549
$cacheKey = '/ex_task_processing_providers';
4650
$records = $this->cache?->get($cacheKey);
4751
if ($records === null) {
4852
$records = $this->mapper->findAllEnabled();
4953
$this->cache?->set($cacheKey, $records);
5054
}
5155

52-
return array_map(static function ($record) {
56+
return $this->registeredProviders = array_map(static function ($record) {
5357
return new TaskProcessingProvider($record);
5458
}, $records);
5559
} catch (Exception) {

0 commit comments

Comments
 (0)