Opened 8 years ago
Closed 8 years ago
#7404 closed enhancement (fixed)
Caching for `xprofile_get_field_from_name()`
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 2.8 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Extended Profile | Keywords: | has-patch 2nd-opinion |
Cc: |
Description
xprofile_get_field_from_name()
can sometimes be called many times on a page load - especially when you're doing a lot of fetching of the Name field. Let's add some caching.
Attachments (1)
Change History (5)
#2
@
8 years ago
This patch works well for me. I was wondering why you went this route instead of adding caching at a lower query level, like the recent improvements to BP_Groups_Group::get()
. It looks like this class could use some updating, generally.
This seems like a nice performance improvement until we get a chance to rethink the Xprofile classes. Thanks!
Note: See
TracTickets for help on using
tickets.
I chose to go with an incrementor cache, so that all field-by-name caches are invalidated whenever a field is updated. I went this route for the following reason. If you have a field 'Foo', it'll be cached with a key 'Foo'. If you then change the name to 'Bar', you have to know that the previous name was 'Foo' in order to invalidate the cache. The way we do field updates - by directly setting the
name
property onBP_XProfile_Field
objects - makes this difficult or impossible to do.Feedback on the approach would be appreciated. See 7404.diff