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

Possible to use with Doctrine Second Level Cache ? #711

Open
Thrillyz opened this issue Aug 11, 2021 · 3 comments
Open

Possible to use with Doctrine Second Level Cache ? #711

Thrillyz opened this issue Aug 11, 2021 · 3 comments

Comments

@Thrillyz
Copy link

Q A
Bundle version 5.6.0
Symfony version 4.4
PHP version 7.4

Support Question

Hi ! I'm using your fabulous bundle but for performances issues i need to use doctrine second level cache with redis.
Second level cache working very well because cache is hitting when i use query result without the paginator bundle. But in case of i'm using it, cache is not writing in the redis DB et was not hit by doctrine. Can you help me ?

Thanks you ! :)

Nicolas

@garak
Copy link
Collaborator

garak commented Aug 11, 2021

Can you provide some examples of how you're using second level cache without paginator? And maybe some examples of how you think you can use it with paginator

@Thrillyz
Copy link
Author

For exemple i have a list view with the paginator that display 40 items per page. I have configured Redis cache pool in my symfony config file. So i would like to use doctrine second level cache to improve page performances.

Here is my controller :

public function index(Request $request, PaginatorInterface $paginator): Response
{
        $itemRepository = $this->getDoctrine()->getManager()->getRepository(Item::class);
        $query = $itemRepository->findAllQuery(); // Give a Query
        $items = $paginator->paginate($query, $request->query->getInt("page", 1), 40);

        return $this->render('items/index.html.twig', [
            'items' => $items,
        ]);
}

But with that, cache is not put in redis
Capture d’écran 2021-08-19 à 11 09 21

So i remove the paginator implementation and then cache is put in Redis :

public function index(): Response
{
        $itemRepository = $this->getDoctrine()->getManager()->getRepository(Item::class);
        $items = $itemRepository->findAll(); // Give a result

        return $this->render('items/index.html.twig', [
            'items' => $items,
        ]);
}

Capture d’écran 2021-08-19 à 11 08 07

Thanks for you help. Hope my explainations is clear :)

@garak
Copy link
Collaborator

garak commented Aug 19, 2021

Can you check the query that retrieves your results? With paginator, it should be the same as without it, except for the limits.
If so, can you try to add a limit to your query by hand and see what happens?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants