We have massive load issues on some bigger systems.
While for many issues cacherouter improves performance it is limited when the lookups lead to empty (NULL) values.
Currently if you persist NULL in the cache it results in a situation where the (drupal) API tells you the same return value as if the cache was missing. Thus all code complexity is being executed again and again just to detect it wasn't needed. This also seems to be a limit of drupal core cache_get / cache_set.
For example: i18nstrings has optional translation for a single string. If many elements miss a translation in a specific language, all lookups fail into NULL. Currently it is impossible to cache these results.
We tried to cache_set NULL values and make sure we get the NULL back. NULL in this case is a fully acceptable result and doesn't mean the cache is incomplete / entry missing.
In our test setup we switches to "NULL" String and had massive improvements. System load drastically reduced by ~50%+.
Do you have any idea how to distinct this working properly?
Comments
Comment #1
andypostGood idea but I'm not sure that we could fix this. http://api.drupal.org/api/function/cache_get/6 is returning 0 if nothing found
OTOH we have static cache that could store this nulls as valid result - I cant make something in upcoming days but glad to retusn this in future
Comment #2
miro_dietikerYou're right.
In case of a null set, cache_get should return the valid $cache object with $cache->data = NULL.
So the isset($cache->data) is wrong. Note that:
http://ch2.php.net/manual/en/function.property-exists.php
This is PHP5.1+ only. But it will allow to check for the property existence.. If needed to be done PHP4 compatible we might convert it to array and use:
http://ch2.php.net/manual/en/function.array-key-exists.php
It is very frustrating that at present PHP state we need to workaround this limitation of popular versions.
I think the best way to solve this issue is checking for something completely different, like
Or even: ($cache is FALSE in case of missing cache entry)
For cacherouter - i think it is perfectly OK to return a $cache->data with value NULL present in case of a cache_set was done by NULL. I didn't see a codeline that will fail, but only seen code that will gain improvement in speedup.