-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Second level cache #808
Second level cache #808
Conversation
Hello, thank you for creating this pull request. I have automatically opened an issue http://www.doctrine-project.org/jira/browse/DDC-2716 We use Jira to track the state of pull requests and the versions they got |
Performance tests CACHE DISABLED doctrine/master
second-level-cache
|
Second level cache performance test using mysql and apc cache
|
The Second Level Cache | ||
====================== | ||
|
||
The Second Level Cache is designed to reduces the amount of necessary database access. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo "reduces"
I'd not have an ON/OFF flag for SL cache. I'm a developer, I turned off SL Cache and want to use Result Cache. This means that we'll store the list of IDs and also each individual Entity on its own cache entry. How it should behave? Are we using the individual Entity entries or not? So, this means to me there's no way to completely disable the SL cache because of consequences it may happen. |
@guilhermeblanco indeed, this ON/OFF might be confuse.. There are 3 points where we check if the config cache is enabled uow, em, query. |
By reading the section on collection caching in the PR description (I haven't looked at the diff at all yet), I'm wondering what happens for the collection cache when an item is removed. Will its id be removed from all collection caches or no ? If no, it will create a proxy to a non-existent object, which will then trigger an exception when being initialized |
@stof Both sides should be aware of this kind of change.. http://planet.jboss.org/post/collection_caching_in_the_hibernate_second_level_cache But i think in this case the missing entity cache will trigger another query to load the collection again, |
<xs:complexType name="entity"> | ||
<xs:sequence> | ||
<xs:element name="cache" type="orm:cache" minOccurs="0" maxOccurs="unbounded"/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maxOccurs="1" everywhere! =D
@doctrine/team-doctrine2 thoughts ? |
unbelivebal! will it available in doctrine 2.5? |
@skydiablo That is the goal.. |
is there a realese date for doctrine 2.5? |
@@ -742,11 +884,10 @@ public function iterate($parameters = null, $hydrationMode = null) | |||
$this->setParameters($parameters); | |||
} | |||
|
|||
$rsm = $this->_resultSetMapping ?: $this->getResultSetMapping(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this will always somehow be extended and manipulating _resultSetMapping
, I wouldn't make this ternary anywhere. Seens in 3 places on this file, and should purely refer to public method.
), $arguments); | ||
} | ||
|
||
public function testInplementsCacheFactory() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inplements -> Implements
done a little review, sorry for the spam |
@pborreli, Thanks for reviewing |
Hi I found problem: $driver = $em->find('CachedDoctrine\Entities\Driver', 1); //Get cached entity dump($driver->getUserProfile()); //Return User $driver->setName('Franta'); $em->flush(); $em->clear(); $driver = $em->find('CachedDoctrine\Entities\Driver', 1); dump($driver->getUserProfile() ); //Return null Sample project |
@CoolLamer please open a separate issue for that on http://www.doctrine-project.org/jira/browse/DDC and provide a test case there (we can't check out an entire project for that - we have a test suite to verify this kind of behavior ;) ) |
…re not an EM's child (FabioBatSilva) This PR was merged into the 2.5-dev branch. Discussion ---------- [Bridge] [DoctrineExtension] Allow cache drivers that are not an EM's child | Q | A | ------------- | --- | Bug fix? | [no] | New feature? | [yes] | BC breaks? | [no] | Deprecations? | [no] | Tests pass? | [yes|] | Fixed tickets | [] | License | MIT | Doc PR | [doctrine/orm#808, doctrine/DoctrineBundle#224] Commits ------- 7528e4c Allow cache drivers that are not an EM's child
…re not an EM's child (FabioBatSilva) This PR was merged into the 2.5-dev branch. Discussion ---------- [Bridge] [DoctrineExtension] Allow cache drivers that are not an EM's child | Q | A | ------------- | --- | Bug fix? | [no] | New feature? | [yes] | BC breaks? | [no] | Deprecations? | [no] | Tests pass? | [yes|] | Fixed tickets | [] | License | MIT | Doc PR | [doctrine/orm#808, doctrine/DoctrineBundle#224] Commits ------- 7528e4c Allow cache drivers that are not an EM's child
i have read, Doctrine 2.5BETA is released. but no words about this great caching feature ? |
@vvh-empora This refers to DBAL, not to ORM. ORM is currently not yet in BETA stage. So expect news for this feature as soon as ORM goes BETA :) |
Hi guys,
I believe, We are coming to an end.. ;)
#580, rebased and reopened to make easier the final review.
Cache strategies
classes / interfaces
Defines a contract for accessing a entity/collection data cache. (Doesn’t employ any locks)
Defines contract for concurrently managed data region. (Locks the data before update/delete.)
Holds timestamps of the most recent entities/tables updates. These timestamps are used as part of the cache for persister queries (findAll, findBy, ...).
Defines entity / collection key to be stored in the cache region.
Build cache entries and rebuild entities/colection from cache
Factory from second level cache components
Collection Caching
The most common use case is to cache entities. But we can also cache relationships.
A “collection cache” caches the primary keys of entities that are members of a collection (OneToMany/ManyToMany).
and each element will be cached into its region.
Only identifiers will be cached for collection. When a collection is read from the second level cache it will create proxies based on the cached identifiers, if the application needs to access an element, Doctrine will go to the cache to load the element data.
Query Cache
The query cache does not cache the state of the actual entities in the result set;
it caches only identifier values for an individual query.
So the query cache should always be used in conjunction with the second-level cache.
Persister Query
(findAll, findBy, ...).
As well as
Query Cache
all persister queries store only identifier values for an individual query.All persister use a single timestamps cache region keeps track of the last update for each persister,
When a query is loaded from cache, the timestamp region is checked for the last update for that persister.
Using the last update timestamps as part of the query key invalidate the cache key when an update occurs.
OPERATIONS
INSERT :
UPDATE :
DELETE :
USAGE :