@@ -31,31 +31,31 @@ Each cache region resides in a specific cache namespace and has its own lifetime
3131Notice that when caching collection and queries only identifiers are stored.
3232The entity values will be stored in its own region
3333
34- Something like below for an entity region :
34+ Something like below for an entity region:
3535
3636.. code-block :: php
3737
3838 <?php
3939 [
40- 'region_name:entity_1_hash' => ['id'=> 1, 'name' => 'FooBar', 'associationName'=> null],
41- 'region_name:entity_2_hash' => ['id'=> 2, 'name' => 'Foo', 'associationName'=> ['id'=> 11]],
42- 'region_name:entity_3_hash' => ['id'=> 3, 'name' => 'Bar', 'associationName'=> ['id'=> 22]]
40+ 'region_name:entity_1_hash' => ['id' => 1, 'name' => 'FooBar', 'associationName' => null],
41+ 'region_name:entity_2_hash' => ['id' => 2, 'name' => 'Foo', 'associationName' => ['id' => 11]],
42+ 'region_name:entity_3_hash' => ['id' => 3, 'name' => 'Bar', 'associationName' => ['id' => 22]]
4343 ];
4444
4545
4646 If the entity holds a collection that also needs to be cached.
47- An collection region could look something like :
47+ An collection region could look something like:
4848
4949.. code-block :: php
5050
5151 <?php
5252 [
53- 'region_name:entity_1_coll_assoc_name_hash' => ['ownerId'=> 1, 'list' => [1, 2, 3]],
54- 'region_name:entity_2_coll_assoc_name_hash' => ['ownerId'=> 2, 'list' => [2, 3]],
55- 'region_name:entity_3_coll_assoc_name_hash' => ['ownerId'=> 3, 'list' => [2, 4]]
53+ 'region_name:entity_1_coll_assoc_name_hash' => ['ownerId' => 1, 'list' => [1, 2, 3]],
54+ 'region_name:entity_2_coll_assoc_name_hash' => ['ownerId' => 2, 'list' => [2, 3]],
55+ 'region_name:entity_3_coll_assoc_name_hash' => ['ownerId' => 3, 'list' => [2, 4]]
5656 ];
5757
58- A query region might be something like :
58+ A query region might be something like:
5959
6060.. code-block :: php
6161
@@ -93,8 +93,6 @@ Cache region
9393``Doctrine\ORM\Cache\Region `` defines a contract for accessing a particular
9494cache region.
9595
96- `See API Doc <https://www.doctrine-project.org/api/orm/current/Doctrine/ORM/Cache/Region.html >`_.
97-
9896Concurrent cache region
9997~~~~~~~~~~~~~~~~~~~~~~~
10098
@@ -105,17 +103,13 @@ If you want to use an ``READ_WRITE`` cache, you should consider providing your o
105103
106104``Doctrine\ORM\Cache\ConcurrentRegion `` defines a contract for concurrently managed data region.
107105
108- `See API Doc <https://www.doctrine-project.org/api/orm/current/Doctrine/ORM/Cache/ConcurrentRegion.html >`_.
109-
110106Timestamp region
111107~~~~~~~~~~~~~~~~
112108
113109``Doctrine\ORM\Cache\TimestampRegion ``
114110
115111Tracks the timestamps of the most recent updates to particular entity.
116112
117- `See API Doc <https://www.doctrine-project.org/api/orm/current/Doctrine/ORM/Cache/TimestampRegion.html >`_.
118-
119113.. _reference-second-level-cache-mode :
120114
121115Caching mode
@@ -132,7 +126,7 @@ Caching mode
132126
133127 * Read Write Cache doesn’t employ any locks but can do reads, inserts, updates and deletes.
134128 * Good if the application needs to update data rarely.
135-
129+
136130
137131* ``READ_WRITE ``
138132
@@ -147,21 +141,21 @@ Built-in cached persisters
147141
148142Cached persisters are responsible to access cache regions.
149143
150- +-----------------------+------------------------------------------------------------------------------------------- +
151- | Cache Usage | Persister |
152- +=======================+=========================================================================================== +
153- | READ_ONLY | Doctrine\\ ORM\\ Cache\\ Persister\\ Entity\\ ReadOnlyCachedEntityPersister |
154- +-----------------------+------------------------------------------------------------------------------------------- +
155- | READ_WRITE | Doctrine\\ ORM\\ Cache\\ Persister\\ Entity\\ ReadWriteCachedEntityPersister |
156- +-----------------------+------------------------------------------------------------------------------------------- +
157- | NONSTRICT_READ_WRITE | Doctrine\\ ORM\\ Cache\\ Persister\\ Entity\\ NonStrictReadWriteCachedEntityPersister |
158- +-----------------------+------------------------------------------------------------------------------------------- +
159- | READ_ONLY | Doctrine\\ ORM\\ Cache\\ Persister\\ Collection\\ ReadOnlyCachedCollectionPersister |
160- +-----------------------+------------------------------------------------------------------------------------------- +
161- | READ_WRITE | Doctrine\\ ORM\\ Cache\\ Persister\\ Collection\\ ReadWriteCachedCollectionPersister |
162- +-----------------------+------------------------------------------------------------------------------------------- +
163- | NONSTRICT_READ_WRITE | Doctrine\\ ORM\\ Cache\\ Persister\\ Collection\\ NonStrictReadWriteCachedCollectionPersister |
164- +-----------------------+------------------------------------------------------------------------------------------- +
144+ +-----------------------+------------------------------------------------------------------------------------------+
145+ | Cache Usage | Persister |
146+ +=======================+==========================================================================================+
147+ | READ_ONLY | `` Doctrine\ORM\Cache\Persister\Entity\ReadOnlyCachedEntityPersister `` |
148+ +-----------------------+------------------------------------------------------------------------------------------+
149+ | READ_WRITE | `` Doctrine\ORM\Cache\Persister\Entity\ReadWriteCachedEntityPersister `` |
150+ +-----------------------+------------------------------------------------------------------------------------------+
151+ | NONSTRICT_READ_WRITE | `` Doctrine\ORM\Cache\Persister\Entity\NonStrictReadWriteCachedEntityPersister `` |
152+ +-----------------------+------------------------------------------------------------------------------------------+
153+ | READ_ONLY | `` Doctrine\ORM\Cache\Persister\Collection\ReadOnlyCachedCollectionPersister `` |
154+ +-----------------------+------------------------------------------------------------------------------------------+
155+ | READ_WRITE | `` Doctrine\ORM\Cache\Persister\Collection\ReadWriteCachedCollectionPersister `` |
156+ +-----------------------+------------------------------------------------------------------------------------------+
157+ | NONSTRICT_READ_WRITE | `` Doctrine\ORM\Cache\Persister\Collection\NonStrictReadWriteCachedCollectionPersister `` |
158+ +-----------------------+------------------------------------------------------------------------------------------+
165159
166160Configuration
167161-------------
@@ -172,7 +166,7 @@ Enable Second Level Cache
172166~~~~~~~~~~~~~~~~~~~~~~~~~
173167
174168To enable the second-level-cache, you should provide a cache factory.
175- ``\ Doctrine\ORM\Cache\DefaultCacheFactory `` is the default implementation.
169+ ``Doctrine\ORM\Cache\DefaultCacheFactory `` is the default implementation.
176170
177171.. code-block :: php
178172
@@ -196,7 +190,7 @@ Cache Factory
196190
197191Cache Factory is the main point of extension.
198192
199- It allows you to provide a specific implementation of the following components :
193+ It allows you to provide a specific implementation of the following components:
200194
201195``QueryCache ``
202196 stores and retrieves query cache results.
@@ -209,8 +203,6 @@ It allows you to provide a specific implementation of the following components :
209203``CollectionHydrator ``
210204 transforms collections into cache entries and cache entries into collections
211205
212- `See API Doc <https://www.doctrine-project.org/api/orm/current/Doctrine/ORM/Cache/DefaultCacheFactory.html >`_.
213-
214206Region Lifetime
215207~~~~~~~~~~~~~~~
216208
@@ -234,7 +226,7 @@ Cache Log
234226~~~~~~~~~
235227By providing a cache logger you should be able to get information about all cache operations such as hits, misses and puts.
236228
237- ``\ Doctrine\ORM\Cache\Logging\StatisticsCacheLogger `` is a built-in implementation that provides basic statistics.
229+ ``Doctrine\ORM\Cache\Logging\StatisticsCacheLogger `` is a built-in implementation that provides basic statistics.
238230
239231 .. code-block :: php
240232
@@ -269,12 +261,9 @@ By providing a cache logger you should be able to get information about all cach
269261 $logger->getMissCount();
270262
271263 If you want to get more information you should implement
272- ``\ Doctrine\ORM\Cache\Logging\CacheLogger `` and collect
264+ ``Doctrine\ORM\Cache\Logging\CacheLogger `` and collect
273265all the information you want.
274266
275- `See API Doc <https://www.doctrine-project.org/api/orm/current/Doctrine/ORM/Cache/Logging/CacheLogger.html >`_.
276-
277-
278267Entity cache definition
279268-----------------------
280269* Entity cache configuration allows you to define the caching strategy and region for an entity.
@@ -330,8 +319,8 @@ level cache region.
330319 Country :
331320 type : entity
332321 cache :
333- usage : READ_ONLY
334- region : my_entity_region
322+ usage : READ_ONLY
323+ region : my_entity_region
335324 id :
336325 id :
337326 type : integer
@@ -401,7 +390,7 @@ It caches the primary keys of association and cache each element will be cached
401390 </id >
402391
403392 <field name =" name" type =" string" column =" name" />
404-
393+
405394 <many-to-one field =" country" target-entity =" Country" >
406395 <cache usage =" NONSTRICT_READ_WRITE" />
407396
@@ -421,7 +410,7 @@ It caches the primary keys of association and cache each element will be cached
421410 State :
422411 type : entity
423412 cache :
424- usage : NONSTRICT_READ_WRITE
413+ usage : NONSTRICT_READ_WRITE
425414 id :
426415 id :
427416 type : integer
@@ -439,17 +428,18 @@ It caches the primary keys of association and cache each element will be cached
439428 country_id :
440429 referencedColumnName : id
441430 cache :
442- usage : NONSTRICT_READ_WRITE
431+ usage : NONSTRICT_READ_WRITE
443432
444433 oneToMany :
445434 cities :
446435 targetEntity:City
447436 mappedBy : state
448437 cache :
449- usage : NONSTRICT_READ_WRITE
438+ usage : NONSTRICT_READ_WRITE
450439
440+ .. note ::
451441
452- > Note: for this to work, the target entity must also be marked as cacheable.
442+ for this to work, the target entity must also be marked as cacheable.
453443
454444Cache usage
455445~~~~~~~~~~~
@@ -466,8 +456,8 @@ Basic entity cache
466456
467457 $country1 = $em->find('Country', 1); // Retrieve item from cache
468458
469- $country1->setName(" New Name" );
470-
459+ $country1->setName(' New Name' );
460+
471461 $em->flush(); // Hit database to update the row and update cache
472462
473463 $em->clear(); // Clear entity manager
@@ -492,7 +482,7 @@ Association cache
492482 $state = $em->find('State', 1);
493483
494484 // Hit database to update the row and update cache entry
495- $state->setName(" New Name" );
485+ $state->setName(' New Name' );
496486 $em->persist($state);
497487 $em->flush();
498488
@@ -550,7 +540,7 @@ The query cache stores the results of the query but as identifiers, entity value
550540 ->setCacheable(true)
551541 ->getResult();
552542
553- $em->clear()
543+ $em->clear();
554544
555545 // Check if query result is valid and load entities from cache
556546 $result2 = $em->createQuery('SELECT c FROM Country c ORDER BY c.name')
@@ -573,7 +563,7 @@ The Cache Mode controls how a particular query interacts with the second-level c
573563 /* @var $em \Doctrine\ORM\EntityManager */
574564 // Will refresh the query cache and all entities the cache as it reads from the database.
575565 $result1 = $em->createQuery('SELECT c FROM Country c ORDER BY c.name')
576- ->setCacheMode(Cache::MODE_GET)
566+ ->setCacheMode(\Doctrine\ORM\ Cache::MODE_GET)
577567 ->setCacheable(true)
578568 ->getResult();
579569
@@ -597,7 +587,7 @@ Execute the ``UPDATE`` and invalidate ``all cache entries`` using ``Query::HINT_
597587 <?php
598588 // Execute and invalidate
599589 $this->_em->createQuery("UPDATE Entity\Country u SET u.name = 'unknown' WHERE u.id = 1")
600- ->setHint(Query::HINT_CACHE_EVICT, true)
590+ ->setHint(\Doctrine\ORM\ Query::HINT_CACHE_EVICT, true)
601591 ->execute();
602592
603593
@@ -712,11 +702,11 @@ For performance reasons the cache API does not extract from composite primary ke
712702 $article = $em->find('Article', $article);
713703
714704 // Supported
715- $id = array( 'source' => 1, 'target' => 2) ;
705+ $id = [ 'source' => 1, 'target' => 2] ;
716706 $reference = $em->find('Reference', $id);
717707
718708 // NOT Supported
719- $id = array( 'source' => new Article(1), 'target' => new Article(2)) ;
709+ $id = [ 'source' => new Article(1), 'target' => new Article(2)] ;
720710 $reference = $em->find('Reference', $id);
721711
722712 Distributed environments
0 commit comments