Skip to content

Commit

Permalink
feat(cache): cache extracted fields from collabora
Browse files Browse the repository at this point in the history
Signed-off-by: Elizabeth Danzberger <lizzy7128@tutanota.de>

[skip ci]
  • Loading branch information
elzody authored and backportbot[bot] committed Aug 19, 2024
1 parent e89e70a commit dbb59a3
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions lib/Service/TemplateFieldService.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,20 @@
use OCP\Files\Template\Field;
use OCP\Files\Template\FieldType;
use OCP\Http\Client\IClientService;
use OCP\ICache;
use OCP\ICacheFactory;
use Psr\Log\LoggerInterface;

class TemplateFieldService {
private ICache $cache;

public function __construct(
private IClientService $clientService,
private CapabilitiesService $capabilitiesService,
private AppConfig $appConfig,
private IRootFolder $rootFolder,
private LoggerInterface $logger
private LoggerInterface $logger,
private ICacheFactory $cacheFactory
) {
}

Expand Down Expand Up @@ -76,7 +81,10 @@ public function extractFields(Node|int $file) {
];
}

return array_merge([], ...$fields);
$fields = array_merge([], ...$fields);
$localCache->set($cacheName, $fields, 3600);

return $fields;
} catch (\Exception $e) {
$this->logger->error($e->getMessage());
return [];
Expand Down

0 comments on commit dbb59a3

Please sign in to comment.