Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add cache for the TagFactory #175

Open
alexander-schranz opened this issue Jan 8, 2021 · 0 comments
Open

Add cache for the TagFactory #175

alexander-schranz opened this issue Jan 8, 2021 · 0 comments
Labels
Performance Problems with performance

Comments

@alexander-schranz
Copy link
Member

alexander-schranz commented Jan 8, 2021

Currently the TagFactory does always request the Tags here and as the query is based on "name" instead of "ids" doctrine will not use its internal cache for it:

https://github.com/sulu/SuluContentBundle/blob/0.4.0/Content/Infrastructure/Doctrine/TagFactory.php#L45-L50

For performance reasons e.g. imports this is not very good maybe we can introduce simple memory based cache e.g.:

// after query result
foreach ($result as $tag) {
    $this->tags[$tag->getName()] = $tag;
}

// after new tag created also add it to the array
$this->tags[$tag->getName()] = $tag;

So we can only query the not yet found tags.

Open Question:

  • Need this cache be invalidated?
    • Edge Case in the same process a Tag is removed
    • EntityManager is cleared (which happens mostly in imports) to clear memory (alternative cache just "id" of the tag instead of the whole object this would keep the memory very low)
@alexander-schranz alexander-schranz added Performance Problems with performance Bug Error or unexpected behavior of already existing functionality and removed Bug Error or unexpected behavior of already existing functionality labels Jan 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Performance Problems with performance
Projects
None yet
Development

No branches or pull requests

1 participant