Make WordPress Core

Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#31618 closed enhancement (invalid)

Filter wp_cache_get return

Reported by: mattkeys's profile mattkeys Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Cache API Keywords:
Focuses: Cc:

Description

This is a bit of an edge case, but there may be a number of situations where this could be useful.

I have run into a situation where under certain circumstances I would like wp_cache_get to return false even if there was cached data to be returned.

Perhaps a filter could be added inside of the get() function in the WP_Object_Cache class to allow me to override the return.

I can provide a patch if anyone agrees with me that this would be nice to have.

Change History (4)

#1 @jipmoors
10 years ago

I would be interested what kind of situation you are talking about.

I cannot imagine it would be functionally sound to ignore data that will remain in the cache taking up space and potentially breaking database/cache synchronisation.

The only thing I can imagine is that you want to have a key expire and in that case you should be using the expiration parameter.

#2 @mattkeys
10 years ago

my situation was a function in a 3rd party plugin which would return early if cached data was found. I wanted to always return false from the cache if the user had admin capabilities.

The need for this was that the function in question contains a number of apply_filters() which never get called if the cache is found and returned.

Having had a full nights sleep on this issue now, it seems the better solution is to contact that plugin author and request that their code is refactored to always fire the filters, even on cached results. And not try to tackle this issue with a filter on wp_cache_get like I outlined in this ticket; unless someone else has a use-case that is valid.

#3 @jipmoors
10 years ago

  • Resolution set to invalid
  • Status changed from new to closed

Sounds like improper use indeed. I hope the developer is active and willing because it would seem like the solution.

#4 @DrewAPicture
10 years ago

  • Milestone Awaiting Review deleted
Note: See TracTickets for help on using tickets.