#13170 closed enhancement (worksforme)
get_term_by() should check object cache
Reported by: | scribu | Owned by: | ryan |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | |
Component: | Cache API | Keywords: | has-patch |
Focuses: | Cc: |
Description
A lot of queries could be saved if get_term_by() would first look in the term cache before calling $wpdb.
Attachments (3)
Change History (12)
#4
@
14 years ago
Maybe add a slug cache.
wp_cache_add($term->slug, $term->term_id, "{$taxonomy}_slugs");
#5
@
14 years ago
- Keywords dev-feedback removed
- Milestone changed from Unassigned to 3.1
In get_terms_by.2.diff: introduce and use wp_cache_get_group()
#6
@
14 years ago
On multisite installs getting a group will return a colossal amount of data. You also can't assume the backend cache will support it. I think the only way we can do this is as we do users, adding a slug to id cache.
#7
@
14 years ago
- Milestone 3.1 deleted
- Resolution set to worksforme
- Status changed from new to closed
Yeah, but that wouldn't cover names.
I think I'll just use a wrapper function for get_term_by()
Note: See
TracTickets for help on using
tickets.
I was thinking of adding a get_group() method to WP_Object_Cache, but I don't want to needlessly clone all the objects in the cache.
Anyway, current patch saved around 25% of queries on a complex front page.