sulu icon indicating copy to clipboard operation
sulu copied to clipboard

Get rid of doctrine/cache dependency

Open sebheitzmann opened this issue 3 years ago • 6 comments

https://github.com/sulu/sulu/blob/c4867cbe8b9f43e03fd2488c3156c0805c998858/src/Sulu/Bundle/CoreBundle/Resources/config/cache.xml#L7

The twig extension use a Memoize class that cache all the data in an Doctrine array cache. The doctrine cache is deprecated.

It's usefull to cache this info in the context of website with user session. The http cache is useless and the default cache has a lifetime of 1 s and is dropped on each connection.

sebheitzmann avatar Aug 10 '22 10:08 sebheitzmann

my page render time is about 7~10 s just because the navigationExtension don't really cache the informations.

sebheitzmann avatar Aug 10 '22 10:08 sebheitzmann

The cache is internal for the current request so multiple calls of the twig extension with the same values don't trigger the database everytime. If you only do it once you should not have too much a problem as the ArrayCache is very fast.

We are aware that the doctrine/cache is deprecated, but on ourside its an easy fix, there are still dependencies like phpcr/jackalope which depends on the doctrine/cache aslong as we have that dependency we don't need to invest here something.

If you are looking for caching the navigation have a look at the https://github.com/sulu/sulu/issues/4084, we recommend that in project having problems with the navigation query. At current state the navigation cache can not included into the core as it will result in unexpected return type and would crash exist project. We target it to change this in 3.0.

PS: Please use when creating issues one of the issue templates (feature request in this case).

alexander-schranz avatar Aug 10 '22 12:08 alexander-schranz

thank you, and sorry for the missed template. I wil try the navigation cache, but the problem is also an the content and structure data which use a lot of request.

sebheitzmann avatar Aug 10 '22 12:08 sebheitzmann

Not sure what you mean with structure data which use a lot of reques if you are using sulu_content_load you should definitly avoid it. It should never be used without selecting specific properties as documented in the docs: https://docs.sulu.io/en/2.5/reference/twig-extensions/functions/sulu_content_load.html And doing it inside a loop is also bad thing which should be avoided.

alexander-schranz avatar Aug 10 '22 12:08 alexander-schranz

thanks for the tips but why can't this be cached more than in the request ?

sebheitzmann avatar Aug 10 '22 12:08 sebheitzmann

Because it is a object. And the object is not serializeable and can not be unserialized the way it is expected. In the example navigation cache we are doing this by generating an array with the properties we require in our project: https://gist.github.com/alexander-schranz/6763148880e60410ed77894ccb585802#file-navigationtwigextension-php-L109 There is currently no general solution as you need to define which properties should be serialized and which one not and that is currently the case why it is not yet part of the core. But we definitly aware of the problem and will be changed in Sulu 3.0 we did just not yet discuss about the configuration for it yet.

alexander-schranz avatar Aug 10 '22 13:08 alexander-schranz