[wp-trac] [WordPress Trac] #20875: Introduce wp_cache_get_multi()
WordPress Trac
wp-trac at lists.automattic.com
Sun Jul 22 06:15:59 UTC 2012
#20875: Introduce wp_cache_get_multi()
-------------------------+------------------------------
Reporter: nacin | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Cache | Version:
Severity: normal | Resolution:
Keywords: has-patch |
-------------------------+------------------------------
Changes (by tollmanz):
* cc: tollmanz@… (added)
* keywords: => has-patch
Comment:
I imagine that there is a lot to be discussed about how this should work,
but I am adding a patch to move things along. I added a first attempt at a
{{{get_multi}}} function with this patch. Additionally, I have written
unit tests and uploaded them here (would appreciate some direction on if
these should also be added to the unit test trac and what's the right way
to do that organizationally).
This {{{get_multi}}} function uses the {{{get}}} function to retrieve
values from the {{{$cache}}} var. An array of keys and groups are sent to
the function. The function attempts to figure out the relationship between
the {{{$keys}}} and {{{$groups}}} values. The logic is:
* If {{{$keys}}} and {{{$groups}}} are both strings, it is assumed to be a
simple get.
* If {{{$keys}}} and {{{$groups}}} are arrays and are the same length,
{{{$keys[n]}}} is assumed to be in {{{$groups[n]}}}.
* If there are more {{{$groups}}} than {{{$keys}}}, {{{$keys[n]}}} is
assumed to be in {{{$groups[n]}}} until all values in {{{$groups}}} is
exhausted. At that point, the remaining {{{$keys}}} values are assumed to
belong to the group 'default'.
* If {{{$keys}}} is an array and {{{$groups}}} is a string or single value
array, all {{{$keys}}} are assumed to be in {{{$groups}}} (if string) or
{{{$groups[0]}}} (if array).
Values are returned as an array with top level keys being groups. The
second level keys are the cache key values. This should match the
organization within the {{{$cache}}} var itself.
A number of different scenarios have been tested in the unit tests and
this seems to be working well for the assumptions I have laid out.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/20875#comment:2>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list