Get cache object by field
|Reported by:||johnbillion||Owned by:|
Functions such as get_term_by() don't check the object cache before performing their query. We should introduce a function for getting a cache object by its field/value pair to make these more efficient.
I've written a simple function, get_cache_object_by(), which accepts $field and $value parameters in the same way get_term_by() does, and an optional $group parameter for the cache group.
get_term_by() and other get_*_by() functions could check the cache with this function before performing their query.
The function is compatible with external object cache plugins that use the cache member variable of the $wp_object_cache object, as they should.