Skip to content

Commit

Permalink
fix: suggested improvements
Browse files Browse the repository at this point in the history
Signed-off-by: Elizabeth Danzberger <[email protected]>
  • Loading branch information
elzody committed Aug 19, 2024
1 parent 6036628 commit beee109
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/Service/TemplateFieldService.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ public function __construct(
private LoggerInterface $logger,
private ICacheFactory $cacheFactory
) {
$this->cache = $cacheFactory->createLocal('richdocuments_templates/');
}

/**
Expand All @@ -50,10 +49,11 @@ public function extractFields(Node|int $file) {
throw new NotFoundException();
}

$localCache = $this->cacheFactory->createLocal('richdocuments_templates/');
$cacheName = $file->getId() . "/" . $file->getEtag();
$cachedResponse = $this->cache->get($cacheName);
$cachedResponse = $localCache->get($cacheName);

if ($cachedResponse) {
if ($cachedResponse !== null) {
return $cachedResponse;
}

Expand Down Expand Up @@ -95,7 +95,7 @@ public function extractFields(Node|int $file) {
}

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

return $fields;
} catch (\Exception $e) {
Expand Down

0 comments on commit beee109

Please sign in to comment.