Skip to content

Commit 9c0e666

Browse files
Merge pull request #503 from nextcloud/backport/500/stable31
[stable31] enh(TaskProcessingService): Cache result of getRegisteredTaskProcessingProviders
2 parents 74069d6 + b513aab commit 9c0e666

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lib/Service/ProvidersAI/TaskProcessingService.php

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

3030
class TaskProcessingService {
3131
private ?ICache $cache = null;
32+
private ?array $registeredProviders = null;
3233

3334
public function __construct(
3435
ICacheFactory $cacheFactory,
@@ -47,14 +48,17 @@ public function __construct(
4748
*/
4849
public function getRegisteredTaskProcessingProviders(): array {
4950
try {
51+
if ($this->registeredProviders !== null) {
52+
return $this->registeredProviders;
53+
}
5054
$cacheKey = '/ex_task_processing_providers';
5155
$records = $this->cache?->get($cacheKey);
5256
if ($records === null) {
5357
$records = $this->mapper->findAllEnabled();
5458
$this->cache?->set($cacheKey, $records);
5559
}
5660

57-
return array_map(static function ($record) {
61+
return $this->registeredProviders = array_map(static function ($record) {
5862
return new TaskProcessingProvider($record);
5963
}, $records);
6064
} catch (Exception) {

0 commit comments

Comments
 (0)