#13170 closed enhancement (worksforme)
get_term_by() should check object cache
| Reported by: | scribu | Owned by: | ryan |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | Cache API | Version: | |
| Severity: | normal | Keywords: | has-patch |
| Cc: | Focuses: |
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
@
16 years ago
Maybe add a slug cache.
wp_cache_add($term->slug, $term->term_id, "{$taxonomy}_slugs");
#5
@
16 years ago
- Keywords dev-feedback removed
- Milestone Unassigned → 3.1
In get_terms_by.2.diff: introduce and use wp_cache_get_group()
#6
@
16 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
@
16 years ago
- Milestone 3.1
- Resolution → worksforme
- Status new → 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.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
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.