Automattic / wp-memcached

Memcached Object Cache for WordPress.
https://wordpress.org/plugins/memcached/
GNU General Public License v2.0
160 stars 55 forks source link

Add wp_cache_get_pre filter #66

Closed joshbetz closed 4 years ago

joshbetz commented 4 years ago

This will let us short-circuit the memcached request. The initial use-case here is to intercept hot keys to store them in a local apcu cache.

rinatkhaziev commented 4 years ago

It seems that WP (mostly) follows the pre_{$someaction} convention, should we change wp_cache_get_pre to be pre_wp_cache_get?

joshbetz commented 4 years ago

@rinatkhaziev Good question. This is the name of the filter on WP.com, so I kept it. I could go either way.

nickdaugherty commented 4 years ago

I'd vote for @rinatkhaziev's idea of sticking to the WP convention.

joshbetz commented 4 years ago

@nickdaugherty @rinatkhaziev What about wp_pre_get_cache, which I think is more consistent with core?

rinatkhaziev commented 4 years ago

Just quickly scoured the hooks reference (pages 42 and further), all of them follow pre_{$function_name} format. E.g. pre_schedule_event, pre_update_option, etc. so if we were to follow the same logic that would be pre_wp_cache_get.

It's no big deal since this is how it's already defined in APC Cache Interceptor and the code is fairly low-level.

joshbetz commented 4 years ago

Ok, fix that filter name and set $found = true when we short-circuit wp_cache_get(). @nickdaugherty @rinatkhaziev can you take one more quick look when you get a chance?

rinatkhaziev commented 4 years ago

@joshbetz I've added a suggestion in the other PR