Opened 18 months ago
Last modified 18 months ago
#19564 new enhancement
Helper function for getting/setting cache data
| Reported by: |
|
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)
Change History (4)
johnjamesjacoby
— 18 months ago
comment:2
scribu
— 18 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
johnbillion
— 18 months ago
- Cc johnbillion@… added
Note: See
TracTickets for help on using
tickets.
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?