Hi everybody,
I have thought a bit recently about how to use getDelayed
and getMulti
in a PHP application, and their difference.
From reading the documentation about getDelayed:
"The method does not wait for response and returns right away. When you are ready to collect the items, call either Memcached::fetch or Memcached::fetchAll."
So obviously there's a need to call fetchAll before having the keys available, unlike getMulti
. But when is the actual memcached call being done?
At fetchAll
or when getDelayed
is run?
Updated with example:
$this->memcached->set('int', 99);
$this->memcached->set('string', 'a simple string');
$this->memcached->set('array', array(11, 12));
$this->memcached->getDelayed(array('int'));
$this->memcached->getDelayed(array('string'));
$this->memcached->getDelayed(array('array'));
print("<pre>".print_r( $this->memcached->fetchAll() )."</pre>"); // returns the array element only.