-
Notifications
You must be signed in to change notification settings - Fork 1k
Description
Feature Request
wp cache type retrieves and displays the type of persistent object cache. Make it more easily extensible.
- Yes, I reviewed the contribution guidelines.
Describe your use case and the problem you are facing
For yet another persistent object cache implementation, this one via SQLite (https://github.com/OllieJones/sqlite-object-cache) it would be nice if thewp cache type command returned something more useful than Unknown.
Describe the solution you'd like
It uses an if / else if cascade in wp_get_cache_type() starting at https://github.com/wp-cli/wp-cli/blob/main/php/utils-wp.php#L255 to look for implementation specifics for each known type of cache and guess the cache type.
Proposal: change near line 256 to add the following bit of code. This will use a method in the cache implementation if it's available to get the cache type.
// Use the get_cache_type method if the cache implements it.
if ( method_exists( $wp_object_cache, 'get_cache_type' ) ) {
$message = $wp_object_cache->get_cache_type();
// Test for Memcached PECL extension memcached object cache (https://github.com/tollmanz/wordpress-memcached-backend)
} elseif ( isset( $wp_object_cache->m ) && $wp_object_cache->m instanceof \Memcached ) {
...This allows future object cache implementations (like mine) to have support from the wp cache type command without needing to embed any more implementation specifics in utils-wp.php. And, future releases of existing caches can easily adapt.