Hello,
When calling taxonomy_get_term_by_name(), the resulting term will be cached again and again on database, even though it is already in the cache table.
The broader issue is that entityCacheLoad(), when called with $conditions instead of $ids (e.g. in this case, $conditions = array(vid=xx and name=xx)), will not find the cached entry (since indexed via the indexKey), and will cache the results every time.
So each time an entity is loaded via $conditions, a cache_set will be done. Not helping performance, especially if your cache tables are still in database.
I know $conditions are apparently deprecated, but some core functions still use that, e.g. taxonomy_get_term_by_name.
A patch is incoming.
Comment | File | Size | Author |
---|---|---|---|
#8 | cache_entities_by_id-1670848.8.patch | 969 bytes | torgosPizza |
Comments
Comment #1
ndeschildre CreditAttribution: ndeschildre commentedThe attached patch will not cache entities loaded in entityCacheLoad with $conditions, since the cache entries cannot be used by calls of entityCacheLoad with $conditions.
Comment #2
johnvThis patch reduces the amount of Queries on my pages a lot.
Tested it by :
- show page: show number of queries with devel_querylog
- enable patch
- refresh page: show number of queries with devel_querylog
- rename a term
- refresh page: change of term is reflected.
Comment #3
Dave ReidThe patch in #1 needs to be adjusted for the coding standards. Comments need a space between the // and the comment text, and if statements need a space in-between the if and the next parenthesis.
Comment #4
colanCleaned it as per the coding standards.
Comment #5
johnvThe new patch applies cleanly and works as expected.
Comment #6
marcelovaniPatch #4 works well. Thanks.
Comment #7
damiankloip CreditAttribution: damiankloip commentedThis generally makes sense.
I think it would be more readable to just do !empty() here.
Comment #8
torgosPizzaHere is a re-roll of the patch from #4 with the change suggested in #7.
Comment #9
DamienMcKennaWe just had another project that was incorrectly running cache_set() because of this problem, and the patch worked great.
Comment #10
skwashd CreditAttribution: skwashd commentedThanks for the patch. I have committed #8 and it will be included in the next release.
Comment #11
skwashd CreditAttribution: skwashd commented