From 193465ad4d5a39657600550af6b8918c3f02dd54 Mon Sep 17 00:00:00 2001 From: Jaroslav Kuba Date: Thu, 28 Jul 2022 21:53:35 +0200 Subject: [PATCH] Added documentation for result caching in QueryBuilder --- docs/en/reference/query-builder.rst | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/docs/en/reference/query-builder.rst b/docs/en/reference/query-builder.rst index 7c33fc51587..4a127ccd8fb 100644 --- a/docs/en/reference/query-builder.rst +++ b/docs/en/reference/query-builder.rst @@ -369,3 +369,26 @@ in your query as a return value: ->where('email = ' . $queryBuilder->createPositionalParameter($userInputEmail)) ; // SELECT id, name FROM users WHERE email = ? + +Caching +------- + +To use the result cache, it is necessary to call the method +``enableResultCache($cacheProfile)`` and pass a instance of +``Doctrine\DBAL\Cache\QueryCacheProfile`` with lifetime in seconds. +Optionally can be specified cache key. + +.. code-block:: php + + select('id', 'name') + ->from('users') + ->enableResultCache(new QueryCacheProfile(300, 'some-key')) + ; + +.. note:: + + For more details and how to configure the result cache check caching section in + documentation.