mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-24 02:38:50 +02:00
Cache the results for the parts of a category for KiCAD
This commit is contained in:
parent
b7af08503c
commit
ee69f9e576
1 changed files with 16 additions and 11 deletions
|
@ -24,6 +24,7 @@ declare(strict_types=1);
|
||||||
namespace App\Services\EDAIntegration;
|
namespace App\Services\EDAIntegration;
|
||||||
|
|
||||||
use App\Entity\Parts\Category;
|
use App\Entity\Parts\Category;
|
||||||
|
use App\Entity\Parts\Part;
|
||||||
use App\EntityListeners\TreeCacheInvalidationListener;
|
use App\EntityListeners\TreeCacheInvalidationListener;
|
||||||
use App\Services\Cache\ElementCacheTagGenerator;
|
use App\Services\Cache\ElementCacheTagGenerator;
|
||||||
use App\Services\Trees\NodesListBuilder;
|
use App\Services\Trees\NodesListBuilder;
|
||||||
|
@ -87,6 +88,9 @@ class KiCADHelper
|
||||||
*/
|
*/
|
||||||
public function getCategoryParts(Category $category): array
|
public function getCategoryParts(Category $category): array
|
||||||
{
|
{
|
||||||
|
return $this->kicadCache->get('kicad_category_parts_' . $category->getID(), function (ItemInterface $item) use ($category) {
|
||||||
|
$item->tag([$this->tagGenerator->getElementTypeCacheTag(Category::class), $this->tagGenerator->getElementTypeCacheTag(Part::class)]);
|
||||||
|
|
||||||
$category_repo = $this->em->getRepository(Category::class);
|
$category_repo = $this->em->getRepository(Category::class);
|
||||||
$parts = $category_repo->getParts($category);
|
$parts = $category_repo->getParts($category);
|
||||||
|
|
||||||
|
@ -100,5 +104,6 @@ class KiCADHelper
|
||||||
}
|
}
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue