cakephp/cakephp — pull request #3137 by Ali1 (2014-03-27 14:33:47+00:00)
Title: Cache library should support memcached getMulti - my proposal

Note: The pull request contains a readMany method which I have tested, but I propose the readMany, writeMany and deleteMany methods which work in a similar fashion.

The main purpose for this proposal is that Memcached supports Memcached:getMulti (http://www.php.net/manual/en/memcached.getmulti.php), setMulti and deleteMulti and the benefit of simultaneous actions is reduced latency times as each action is typically associated with a TCP request.

There is currently no good way of taking advantage of the speed benefits of simultaneous actions which I propose we work on. Updating the Cache library to support multiple read, writes and deletes is the first step to then allow cache engines to optionally implement them and take advantage of their respective engines - I believe WinCache also supports multiple actions in one request.

Any implementation needs to be backwards compatible so that existing engines work fine without changes even if Cache::readMany, Cache::writeMany or Cache::deleteMany are used in the application - and we can do this by having smart methods in the Cache class. I've written the code here so that Cache::readMany will work exactly the same for any engine, regardless of whether they implement simultaneous actions or not. readMany may actually be more convenient that read in some cases (wherever one uses foreach loop for Cache::read).

Next steps: Also implement Cache::writeMany, Cache::deleteMany and modify MemcachedEngine (and others) to implement MemcachedEngine::readMany, MemcachedEngine::writeMany and MemcachedEngine::deleteMany to use Memcached::getMulti, Memcached::setMulti and Memcached::deleteMulti.