mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
DDC-2981: Multi get for second level cache (Doctrine Cache related) #3710
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?
Originally created by @doctrinebot on GitHub (Feb 13, 2014).
Originally assigned to: @Ocramius on GitHub.
Jira issue originally created by user goetas:
Hi every body!
I'm developing an application that is highly based on doctrine second-level cache feature.
Using memcache or redis as cache back-end, doctrine have to query thousand times for the cached values (especially on one-to-many and many-to-many associations).
This introduces a lot of latency (and network traffic)...
I'm thinking to add to
Doctrine\Common\Cache\Cacheinterface a methodfetchMulti(array $keys)that fetches multiple items in one call. In this way doctrine orm can ask for many items with just one call (for example, here https://github.com/doctrine/doctrine2/blob/master/lib/Doctrine/ORM/Cache/DefaultCollectionHydrator.php#L84 this feature can be very useful).I have made some real-world tests and it can reduce highly the number of total queries (my app runs 190 cache requests instead of 900 cache requests)
Many vendors (memcache, redis, apc ecc) already offer this functionality, but with doctrine-cache we can't use it...
I'm going to implement this feature. Can it be accepted as a pull request?
It may be BC breaking:
Doctrine\Common\Cache\Cacheinterface (more BC breaking but more clean and elegant)Doctrine\Common\Cache\MultiCacheand laterCacheProvidercan implement it (less BC breaking)@doctrinebot commented on GitHub (Feb 13, 2014):
@doctrinebot commented on GitHub (Feb 13, 2014):
Comment created by @ocramius:
Adding a method to
Doctrine\Common\Cache\Cacheis not viable because of BC - a new interface would be ok@doctrinebot commented on GitHub (Feb 13, 2014):
Comment created by goetas:
ok, i agree with you.
But this forces me to check always here https://github.com/doctrine/doctrine2/blob/master/lib/Doctrine/ORM/Cache/Region/DefaultRegion.php#L95 if
$this->cacheis instance ofMultiCache@doctrinebot commented on GitHub (Feb 13, 2014):
Comment created by @ocramius:
[~goetas] or you build a
MultiCacheRegion@doctrinebot commented on GitHub (Feb 13, 2014):
Comment created by goetas:
It can be a good approach. I will try it.
I'm thinking to provide a default implementation of
fetchMultidirectly insideCacheProviderthat internally loops over each key and callCacheProvider::fetch($id)to fetch its value.Later i will overwrite this behavior inside vendor specific driver (
ApcCache,RedisCache...)@doctrinebot commented on GitHub (Jan 17, 2015):
Comment created by @ocramius:
Solved in DDC-2982
@doctrinebot commented on GitHub (Jan 17, 2015):
Issue was closed with resolution "Fixed"