PHP memcached: getDelayed & getMulti - how to use?

I thought a bit about how to use getDelayedboth the getMultiPHP application and their difference.

From reading the documentation for getDelayed:

"The method does not wait for an answer and immediately returns. When you are ready to collect the items, call either Memcached :: fetch or Memcached :: fetchAll."

Thus, it is obvious that you need to call fetchAll before you have the keys available, unlike getMulti. But when is the actual memcached call made? At fetchAllor at startup getDelayed?

Updated with an 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.
+3
source share
2 answers

Memcache IO occurs either on getDelayedor fetchAll.

getDelayed : " , ".

, PHP . , , PHP , , fetchAll.

PHP , fetchAll, . , , Memcached .

: :

  • , 3 .
  • 100 memcache, 2 .

, getMulti, 5 .

getDelayed , , fetchAll, 3 .

+4

. , getDelayed, memcache , , , . , PHP script , , memcache . , , fetchAll. , fetchAll, . , , .

getMulti fetchAll blocking. , . getDelayed , , , ( "" , ).

, getDelayed, : , , , , memcached (, html). , , getDelayed. , , .. , fetchAll, script. , , , .

+3

Source: https://habr.com/ru/post/1747535/


All Articles