Open superdav42 opened 5 years ago
This appears to have been fixed by Automattic for WordPress.com VIP customers in the copy of this plugin at https://github.com/Automattic/vip-go-mu-plugins/tree/develop/drop-ins/wp-memcached as part of https://github.com/Automattic/vip-go-mu-plugins/commit/da8a798b680dc123ad9b15f8df1a9e1099f8b274.
The memcached
plugin on WordPress.org is now 3 years out of date. There are several changes and PHP 8.2 fixes here in the main branch, unreleased, and several more fixes in vip-go-mu-plugins that are neither commited nor released.
@WPprodigy Is there a timeline for when these are folded back in? The patches there don't look like breaking, large, or high-frequency changes so I wonder what led to the copy being preferred, or what risk there would be with committing them here instead (and updating the submodule).
In any event, in the interim, merging these two fixes and a release for these and previously merged fixes, would be great!
Hi!
So the newer plugin is mainly built for the Memcached
PHP extension using the libmemcached
library, whereas this plugin is built for the older Memcache
php extension (programmers naming things 😅).
I do agree though, it would be good to port over the normalize_key()
behavior into this plugin. The way Memcache
automatically strips the key after 250chars does feel rather flakey and asking for potential collisions and some very unfun debugging sessions.
@WPprodigy Yeah, I'm aware of the difference in PECL extensions used. I believe numerous forks and PRs exist that add support for that. Are you open to that direction still, where both are supported and auto-detected together, keeping this plugin as the main plugin? (I'd favour, like you probably, to check the libmemcached-based php-memcached, first, in case both are installed for some reason.).
It seems like that would be doable without a compat break, and fairly minimal code complexity increase. Basically a handful of "if" statements (or, if we prefer composition, by invoking one of two compatible sub classes in get_mc
, and taking it from there). I hope to avoid a long term split and bifurcation in code, docs, support forum, bug reports, installation improvements, code contributions, tutorials, links from blog posts etc; since the vast majority of that doesn't vary by client class.
Memcache has a key length limit of 250 characters. Problems can arise if a cache key greater than this is used. It seems memcache truncates the key so it is very possible to have collisions and unexpected behavior. Other object caches can handle very large keys so this object cache should check if a key is too long and hash it with md5 or similar to prevent problems.