#31618 closed enhancement (invalid)
Filter wp_cache_get return
Reported by: | 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)
#2
@
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.
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.