mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
[PR #580] [CLOSED] [WIP] Second level cache #8402
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/doctrine/orm/pull/580
Author: @FabioBatSilva
Created: 2/14/2013
Status: ❌ Closed
Base:
master← Head:second-level-cache📝 Commits (10+)
8fe90d1Second cache level POC52d4b88First round of refactory55146a3Fix factory method name0731254refactoring region access tests9466a44basically support for many to many collectiond532fdfRefactoring tests3468ed7store cascade collectionsb062340refactoring collections store2904ecfhandle one to many collections storage0ee0833tests put entities on persist📊 Changes
141 files changed (+14619 additions, -381 deletions)
View changed files
📝
.travis.yml(+7 -4)📝
docs/en/index.rst(+1 -0)➕
docs/en/reference/second-level-cache.rst(+802 -0)📝
docs/en/toc.rst(+8 -4)📝
doctrine-mapping.xsd(+18 -0)📝
lib/Doctrine/ORM/AbstractQuery.php(+220 -8)➕
lib/Doctrine/ORM/Cache.php(+185 -0)➕
lib/Doctrine/ORM/Cache/CacheEntry.php(+32 -0)➕
lib/Doctrine/ORM/Cache/CacheException.php(+72 -0)➕
lib/Doctrine/ORM/Cache/CacheFactory.php(+95 -0)➕
lib/Doctrine/ORM/Cache/CacheKey.php(+36 -0)➕
lib/Doctrine/ORM/Cache/CollectionCacheEntry.php(+51 -0)➕
lib/Doctrine/ORM/Cache/CollectionCacheKey.php(+60 -0)➕
lib/Doctrine/ORM/Cache/CollectionHydrator.php(+54 -0)➕
lib/Doctrine/ORM/Cache/ConcurrentRegion.php(+59 -0)➕
lib/Doctrine/ORM/Cache/DefaultCache.php(+346 -0)➕
lib/Doctrine/ORM/Cache/DefaultCacheFactory.php(+193 -0)➕
lib/Doctrine/ORM/Cache/DefaultCollectionHydrator.php(+103 -0)➕
lib/Doctrine/ORM/Cache/DefaultEntityHydrator.php(+151 -0)➕
lib/Doctrine/ORM/Cache/DefaultQueryCache.php(+294 -0)...and 80 more files
📄 Description
Hi guys. :)
After a look into some implementations I end up with the following solution for the second level cache..
There is lot of work todo before merge it, but i'd like to get your thoughts before i go any further on this approach.
I hope my drafts are good enough to explain the idea :
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.)
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.
Query Cache validation
OPERATIONS
INSERT :
UPDATE :
DELETE :
USAGE :
TODO :
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.