downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

Memcache::get> <Memcache::delete
[edit] Last updated: Fri, 25 May 2012

view this page in

Memcache::flush

(PECL memcache >= 1.0.0)

Memcache::flushEfface tous les éléments existant sur le serveur de cache

Description

bool Memcache::flush ( void )

Memcache::flush() invalide immédiatement tous les éléments existant sur le serveur de cache. Memcache::flush() ne libère aucune ressource actuellement, il marque uniquement tous les éléments comme ayant expirés, donc la mémoire occupée sera réutilisée avec de nouveaux éléments. Vous pouvez également utiliser la fonction memcache_flush().

Valeurs de retour

Cette fonction retourne TRUE en cas de succès ou FALSE si une erreur survient.

Exemples

Exemple #1 Exemple avec Memcache::flush()

<?php

/* API procédurale */
$memcache_obj memcache_connect('memcache_host'11211);

memcache_flush($memcache_obj);

/* API orientée objet */

$memcache_obj = new Memcache;
$memcache_obj->connect('memcache_host'11211);

$memcache_obj->flush();

?>



add a note add a note User Contributed Notes Memcache::flush
Anonymous 27-Feb-2008 07:51
From the memcached mailing list:

"The flush has a one second granularity. The flush will expire all items up to the ones set within the same second."

It is imperative to wait at least one second after flush() command before further actions like repopulating the cache. Ohterwise new items < 1 second after flush() would be invalidatet instantaneous.

Example:
<?php
$memcache
->flush();

$time = time()+1; //one second future
while(time() < $time) {
 
//sleep
}
$memcache->set('key', 'value'); // repopulate the cache
?>
maarten d/ot manders a/t tilllate dotcom 12-Jul-2007 01:20
Please note that after flushing, you have to wait a certain amount of time (in my case < 1s) to be able to write to Memcached again. If you don't, Memcached::set() will return 1, although your data is in fact not saved.

 
show source | credits | sitemap | contact | advertising | mirror sites