stuttter / wp-spider-cache

Your friendly neighborhood caching solution for WordPress
GNU General Public License v2.0
134 stars 16 forks source link

Support Memcached (not Memcache) #19

Open swissspidy opened 8 years ago

swissspidy commented 8 years ago

Currently, if the Memcache extension is not installed (but the Memcached extension is), there is a fatal error in includes/class-object-cache.php.

If I manually change WP_Spider_Cache_Object::$engine_class_name to 'Memcached', there is no fatal error any more, but in the back-end I get a notice that I should install the Memache extension.

screen shot 2016-08-11 at 12 06 34

First of all, I don't think anyone will ever see that notice because of the fatal error. Second, mixing up Memcache and Memcached throughout the code base is confusing.

Both are PHP extensions to access a Memcached server. Why are their names used interchangeably in this plugin when clearly the Memcache extension is required?

Sorry if I'm missing something, haven't had my coffee yet :-)

JJJ commented 8 years ago

Memcache is only used for its getExtendedStats() method, which is what's responsible for connecting to the server to allow us to interact with cached contents.

Memcached has a getStats() method, but it's not as comprehensive and won't allow us to interact with the cached contents themselves.

So, the very simple and nondescript notice you see in your screenshot, is my way of saying "This interface will not work without Memcache installed, but Memcached will continue to work OK."

JJJ commented 8 years ago

I think there might be some conflation between the engine and daemon terminologies, too. I'll look at cleaning these up soon.

JJJ commented 8 years ago

Okay. Cleaned some things up, but there is more to do.

Not today, unfortunately, but I have in my mind what needs to happen:

JJJ commented 8 years ago

Related: #6.

todeveni commented 7 years ago

Subscribing to this, since the official memcache extension doesn't build for PHP7 and seems abandoned. Sure there is one or two forked versions, but...

JJJ commented 7 years ago

General update: I've made some nominal changes surrounding this to try and support additional backends (Redis, mostly) but nothing substantial.

I'm reluctant to litter the codebase with caveats and constants to guide the engine/daemon relationships, but it may be necessary eventually. (WP Redis has a bunch, and I assume they're useful there.)

JJJ commented 7 years ago

Related: #25.

ihorvorotnov commented 7 years ago

Subscribing to this. Trying to make it work with Memcached and exploring the code right now.

bueltge commented 7 years ago

I mean the plugin supports Memcached, only a change in https://github.com/stuttter/wp-spider-cache/blob/master/wp-spider-cache/includes/class-object-memcached.php#L30 to Memcached is to do and it works also wit PHP7* and Memcached.

public $engine_class_name = 'Memcache';

should change to

public $engine_class_name = 'Memcached';

The class, there you use is Memcached https://github.com/stuttter/wp-spider-cache/blob/6ee2c2726f444fd91b475608c51f10569dbb2273/wp-spider-cache/includes/class-object-memcached.php#L70

        // Set daemon flags
        if ( class_exists( $this->daemon_class_name ) ) {
            $this->success_code   = Memcached::RES_SUCCESS;
            $this->preserve_order = Memcached::GET_PRESERVE_ORDER;
        }

The plugin don't supports Memcache, there is really old - I mean 2013 last support change.

I had tested this change in one environment and it works without problems. If you need an pull request, please ping me. Best.