From 72785eb27e24e364570ef8374028f29d406406f6 Mon Sep 17 00:00:00 2001 From: Javier Spagnoletti Date: Fri, 23 Jan 2015 11:23:21 -0300 Subject: [PATCH] [Doc][Reference][2nd level cache] * Fixed typo in TimestampRegion title. * Normalized php snippets (comments, indentation). --- docs/en/reference/second-level-cache.rst | 65 ++++++++++-------------- 1 file changed, 28 insertions(+), 37 deletions(-) diff --git a/docs/en/reference/second-level-cache.rst b/docs/en/reference/second-level-cache.rst index 5408ca97c..a115d9c8e 100644 --- a/docs/en/reference/second-level-cache.rst +++ b/docs/en/reference/second-level-cache.rst @@ -113,8 +113,8 @@ Defines contract for concurrently managed data region. `See API Doc `_. -Cache region -~~~~~~~~~~~~ +Timestamp region +~~~~~~~~~~~~~~~~ ``Doctrine\ORM\Cache\TimestampRegion`` @@ -183,16 +183,15 @@ To enable the second-level-cache, you should provide a cache factory .. code-block:: php setSecondLevelCacheEnabled(); - //Cache factory + // Cache factory $config->getSecondLevelCacheConfiguration() ->setCacheFactory($factory); @@ -220,13 +219,12 @@ To specify a default lifetime for all regions or specify a different lifetime fo .. code-block:: php getSecondLevelCacheConfiguration(); $regionConfig = $cacheConfig->getRegionsConfiguration(); - //Cache Region lifetime + // Cache Region lifetime $regionConfig->setLifetime('my_entity_region', 3600); // Time to live for a specific region; In seconds $regionConfig->setDefaultLifetime(7200); // Default time to live; In seconds @@ -240,11 +238,10 @@ By providing a cache logger you should be able to get information about all cach .. code-block:: php setSecondLevelCacheEnabled(true); $config->getSecondLevelCacheConfiguration() ->setCacheLogger($logger); @@ -457,7 +454,6 @@ Basic entity cache .. code-block:: php persist(new Country($name)); $em->flush(); // Hit database to insert the row and put into cache @@ -480,7 +476,6 @@ Association cache .. code-block:: php persist(new State($name, $country)); $em->flush(); @@ -543,20 +538,19 @@ The query cache stores the results of the query but as identifiers, entity value .. code-block:: php createQuery('SELECT c FROM Country c ORDER BY c.name') + ->setCacheable(true) + ->getResult(); - // Execute database query, store query cache and entity cache - $result1 = $em->createQuery('SELECT c FROM Country c ORDER BY c.name') - ->setCacheable(true) - ->getResult(); + $em->clear() - $em->clear() - - // Check if query result is valid and load entities from cache - $result2 = $em->createQuery('SELECT c FROM Country c ORDER BY c.name') - ->setCacheable(true) - ->getResult(); + // Check if query result is valid and load entities from cache + $result2 = $em->createQuery('SELECT c FROM Country c ORDER BY c.name') + ->setCacheable(true) + ->getResult(); Cache mode ~~~~~~~~~~ @@ -571,13 +565,12 @@ The Cache Mode controls how a particular query interacts with the second-level c .. code-block:: php createQuery('SELECT c FROM Country c ORDER BY c.name') - ->setCacheMode(Cache::MODE_GET) - ->setCacheable(true) - ->getResult(); + /* @var $em \Doctrine\ORM\EntityManager */ + // Will refresh the query cache and all entities the cache as it reads from the database. + $result1 = $em->createQuery('SELECT c FROM Country c ORDER BY c.name') + ->setCacheMode(Cache::MODE_GET) + ->setCacheable(true) + ->getResult(); .. note:: @@ -636,7 +629,6 @@ Using the last update timestamps as part of the query key invalidate the cache k .. code-block:: php getRepository('Entity\Country')->findAll(); @@ -661,8 +653,7 @@ However, you can use the cache API to check / invalidate cache entries. .. code-block:: php getCache(); $cache->containsEntity('Entity\State', 1) // Check if the cache exists