WordPress.org

Make WordPress Core

Opened 18 months ago

Last modified 18 months ago

#19564 new enhancement

Helper function for getting/setting cache data

Reported by: johnjamesjacoby Owned by:
Priority: normal Milestone: Awaiting Review
Component: Cache Version: 3.3
Severity: normal Keywords: has-patch
Cc: johnbillion@…

Description

Most of the time when we want something from the object cache we go through a routine of: wp_cache_get(); checking a result; setting a default; setting the cache with wp_cache_set(); returning. Core should offer a neat way to do this all in one fell-swoop.

Attached patch is a proposed solution.

Attachments (1)

19564.patch (1.3 KB) - added by johnjamesjacoby 18 months ago.

Download all attachments as: .zip

Change History (4)

johnjamesjacoby18 months ago

comment:1 scribu18 months ago

I've never needed to set a default when a cache value is not present.

Could you provide a usage example for the new function?

comment:2 scribu18 months ago

I'm particularly interested in how the callback parameter would work, knowing that generating a value to be cached would require various bits of information from the current context.

comment:3 johnbillion18 months ago

  • Cc johnbillion@… added
Note: See TracTickets for help on using tickets.